{{ message }}
Produce OpenAPI document describing CCF's endpoints#1612
Merged
Conversation
Member
Author
Member
|
@eddyashton do we want to target that directly? |
ashamis
reviewed
Sep 16, 2020
achamayou
reviewed
Sep 18, 2020
achamayou
reviewed
Sep 18, 2020
…openapi_generation2
Member
Author
achamayou
approved these changes
Sep 24, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Had this on the side for a while, finally got it into a place where (I think) it mostly works. Opening as a draft PR to see what's still missing, includes a few TODOs.
The core change is that the
/apiendpoint now returns an OpenAPI document, rather than just a list of paths. This involves some changes to our JSON schema-generating macros, to populate an OpenAPI document rather than returning isolated elements. For full customisability (ie - so the apps can, if they wish, store a separate document or elements and merge them in), we manipulate the OpenAPI document as a raw JSON document, with some helper functions to try and put things in the right place. This is more error prone than a strongly typed wrapper, but I think the flexibility is necessary.There are 2 test for this. There's an
openapi_testunit test, which really only tests compilation of the helper functions + custom types, and does minimal validation that the result looks like a plausible document. Then the existingschema.pye2e test now uses a 3rd party OpenAPI validation library to check that the produced documents are valid OpenAPI. This seems unhappy with some things the online validator was happy with ($schemaelements in particular), so I've removed a few useful-but-non-essential features to support it. This test also dumps the documents like it does the individual schema responses, and I've been running those documents through the online swagger validator - this is almost happy, but doesn't like nlohmann::json's "maps are lists of tuples" representations, as OpenAPI schema breaks from JSON schema in disallowing tuples.