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

[OpenAPI] Extract the JSON Schema builder #2983

Merged
merged 3 commits into from Aug 19, 2019

Conversation

@dunglas
Copy link
Member

commented Aug 13, 2019

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #2715, #2415, #2502, api-platform/api-platform#1222
License MIT
Doc PR todo

Introduce a new service allowing to generate a JSON Schema from any class, including those marked with @ApiResource.

It's an alternative approach to #2715 to support specific JSON Schemas per MIME type in OpenAPI (this part is not ready yet).
It will also allow to generate JSON Schema directly, without having to rely on OpenAPI. It can be practical for validation, or to use libraries such as https://github.com/mozilla-services/react-jsonschema-form

This new capability will also replace https://github.com/dunglas/php-to-json-schema

TODO:

  • Add support for formats
@dunglas

This comment has been minimized.

Copy link
Member Author

commented Aug 14, 2019

I added support for the writeOnly and deprecated fields defined by the JSON Schema spec. I also refactored heavily the code.

@dunglas

This comment has been minimized.

Copy link
Member Author

commented Aug 15, 2019

AppVeyor failure related to symfony/symfony#32879 (fixed in 4.3-dev). Ignoring for now.

@dunglas dunglas force-pushed the dunglas:extract-schema-builder branch 2 times, most recently from b230729 to a8a8806 Aug 15, 2019

@dunglas dunglas marked this pull request as ready for review Aug 18, 2019

@dunglas

This comment has been minimized.

Copy link
Member Author

commented Aug 18, 2019

DocumentationNormalizer can be simplified a bit more, and unit tests must be added for the new classes, but it works!

image

@dunglas dunglas force-pushed the dunglas:extract-schema-builder branch from cf50ef6 to c421a61 Aug 19, 2019

@dunglas dunglas force-pushed the dunglas:extract-schema-builder branch from c421a61 to c63e635 Aug 19, 2019

dunglas added 2 commits Aug 19, 2019

@dunglas dunglas merged commit e8f26ca into api-platform:master Aug 19, 2019

10 of 11 checks passed

SymfonyInsight: dunglas / API Platform Core Your analysis has been queued.
Scrutinizer Analysis: 4 new issues, 31 updated code elements – Tests: passed
Details
ci/circleci: behat-coverage Your tests passed on CircleCI!
Details
ci/circleci: behat-elasticsearch-coverage Your tests passed on CircleCI!
Details
ci/circleci: behat-mongodb-coverage Your tests passed on CircleCI!
Details
ci/circleci: php-cs-fixer Your tests passed on CircleCI!
Details
ci/circleci: phpstan Your tests passed on CircleCI!
Details
ci/circleci: phpunit-coverage Your tests passed on CircleCI!
Details
ci/circleci: phpunit-mongodb-coverage Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.