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

api: switch to yaml for openapi spec snapshot test #3943

Conversation

BacLuc
Copy link
Contributor

@BacLuc BacLuc commented Oct 10, 2023

It supports multi line string values, the url's are not escaped and you can navigate from type usage to the definition by clicking on it in Jetbrains Products, and it should be easier to diff and merge than json.

api: switch to yaml format in ResponseSnapshotTest::testOpenApiSpecMatchesSnapshot

Because yaml can more easily be merged and diffed.
Use our own copy of the YamlSnapshotDriver, because for some
reason the yaml is parsed again if it is a string
and then dumped with different parameters, which leads to an
invalid openapi yaml file.

@BacLuc BacLuc force-pushed the api-switch-to-yaml-for-openapi-spec-snapshot-test branch from 8fa86ea to 4290d52 Compare October 10, 2023 16:28
@carlobeltrame
Copy link
Member

carlobeltrame commented Oct 20, 2023

In API Platform 3.2, you can still retrieve the JSON OpenAPI spec if you add the following line to api_platform.yaml:

    docs_formats:
        jsonhal: [ 'application/hal+json' ]
        jsonld: [ 'application/ld+json' ]
        jsonapi: [ 'application/vnd.api+json' ]
        jsonopenapi: ['application/vnd.openapi+json'] # <-- add this
        html: [ 'text/html' ]

And then use the endpoint /api/docs.jsonopenapi instead of /api/docs.json as was previously available.

@BacLuc BacLuc force-pushed the api-switch-to-yaml-for-openapi-spec-snapshot-test branch from 4290d52 to da43b7f Compare October 20, 2023 22:09
…tchesSnapshot

Because yaml can more easily be merged and diffed.
Use our own copy of the YamlSnapshotDriver, because for some
reason the yaml is parsed again if it is a string
and then dumped with different parameters, which leads to an
invalid openapi yaml file.
@BacLuc BacLuc force-pushed the api-switch-to-yaml-for-openapi-spec-snapshot-test branch from da43b7f to 5dcf695 Compare October 20, 2023 22:12
Copy link
Member

@carlobeltrame carlobeltrame left a comment

Choose a reason for hiding this comment

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

Thanks, much simpler now

@carlobeltrame carlobeltrame added this pull request to the merge queue Oct 21, 2023
Merged via the queue into ecamp:devel with commit 13d4330 Oct 21, 2023
28 checks passed
@BacLuc BacLuc deleted the api-switch-to-yaml-for-openapi-spec-snapshot-test branch December 23, 2023 19:10
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.

None yet

3 participants