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

Refactor OpenAPI conversion #275

Merged
merged 4 commits into from
Feb 15, 2020
Merged

Refactor OpenAPI conversion #275

merged 4 commits into from
Feb 15, 2020

Conversation

mtdowling
Copy link
Member

Refactor OpenAPI to use traits & inline schemas

This updates the OpenAPI converter to deal with how the JSON schema
converter is now automatically inlining different types of members.
The produced artifacts are basically the same as the previously produced
"inlined" OpenAPI shemas. One major change is that previously numbers
were never inlined due to a bug.

The conversion is now generically typed based on the protocol trait being
converted. This gives access to any protocol configuration data. Auth scheme
conversion is now generically typed based on the auth trait too, also giving
access to auth scheme trait configuration data. These two changes required
some moderate changes to various APIs.

Various cleanup and readability changes were made to the protocol conversion
code. However, this should not have affected the output.

Ensure that schemaDocumentExtensions are added

Use $ref for request/response OpenAPI contents

We previously generated inline schemas for the contents (document
bindings) of requests and responses. This resulted in randomly generated
schemas in some tools like API Gateway. This change now adds the ability
to "synthesize" shapes during the conversion so that we can now generate
schemas for these cases.

This change also detected and fixed a bug where the headers of an
operations's response were being used when generating errors responses
rather than the header bindings on the error.

Add more context to OpenAPI mappers and fix CORS

This commit adds more contextual information that might be relevant to
different OpenAPI mapper methods, including the HTTP method and path
associated with what's being mapped over. Further, this gives more
context to the CORS integration for API Gateway to ensure that headers
are only added for the appropriate type of request (preflight vs CORS
request).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from kstich February 14, 2020 18:24
@mtdowling mtdowling changed the title Refactor openapi Refactor OpenAPI conversion Feb 14, 2020
This updates the OpenAPI converter to deal with how the JSON schema
converter is now automatically inlining different types of members.
The produced artifacts are basically the same as the previously produced
"inlined" OpenAPI shemas. One major change is that previously numbers
were never inlined due to a bug.

The conversion is now generically typed based on the protocol trait being
converted. This gives access to any protocol configuration data. Auth scheme
conversion is now generically typed based on the auth trait too, also giving
access to auth scheme trait configuration data. These two changes required
some moderate changes to various APIs.

Various cleanup and readability changes were made to the protocol conversion
code. However, this should not have affected the output.
We previously generated inline schemas for the contents (document
bindings) of requests and responses. This resulted in randomly generated
schemas in some tools like API Gateway. This change now adds the ability
to "synthesize" shapes during the conversion so that we can now generate
schemas for these cases.

This change also detected and fixed a bug where the headers of an
operations's response were being used when generating errors responses
rather than the header bindings on the error.
This commit adds more contextual information that might be relevant to
different OpenAPI mapper methods, including the HTTP method and path
associated with what's being mapped over. Further, this gives more
context to the CORS integration for API Gateway to ensure that headers
are only added for the appropriate type of request (preflight vs CORS
request).
@mtdowling mtdowling changed the base branch from rewrite-jsonschema to 0.10 February 14, 2020 21:47
@mtdowling mtdowling merged commit 3ca399f into 0.10 Feb 15, 2020
@mtdowling mtdowling deleted the refactor-openapi branch February 15, 2020 19:32
@kstich kstich mentioned this pull request Apr 23, 2020
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