Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'components' section in openapi 3.0.0 #119

Merged
merged 3 commits into from
Dec 17, 2019

Conversation

brucify
Copy link
Contributor

@brucify brucify commented Dec 16, 2019

Currently, add_definition/1 always adds to the definitions: section in swagger.json and schema/1 hardcodes to fetch from <<"#/definitions/", DefinitionName/binary>>.

Open API 3.0.0 has removed the #/definitions/ section and introduced #/components/schemas/ (Components Section)

OpenAPI 2.0                    OpenAPI 3.0
'#/definitions/User'         → '#/components/schemas/User'

This causes:

Structural error at 
should NOT have additional properties
additionalProperty: definitions
Jump to line 0

This PR adds support to point add_definition/1 and schema/1 to "components" section if openapi: "3.0.0" is defined. For swagger: "2.0", it will still add to "definitions" section.

@brucify brucify force-pushed the openapi_3_0_0_components branch from 083ce3a to fe4d3f0 Compare December 16, 2019 21:09
@brucify brucify force-pushed the openapi_3_0_0_components branch from fe4d3f0 to 60eae30 Compare December 16, 2019 23:19
Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we adjust the tests to explicitly test the different versions separately?

@@ -68,6 +69,12 @@
-type metadata() :: trails:metadata(swagger_map()).
-export_type([swagger_map/0, metadata/0]).

-define(SWAGGER_2_0, swagger_2_0).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really like to use macros for these things. Can you just use the atoms everywhere and trust dialyzer? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@elbrujohalcon elbrujohalcon merged commit a4d492b into inaka:master Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants