Skip to content

Comments

[OpenAPI] Extract the JSON Schema builder#2983

Merged
dunglas merged 3 commits intoapi-platform:masterfrom
dunglas:extract-schema-builder
Aug 19, 2019
Merged

[OpenAPI] Extract the JSON Schema builder#2983
dunglas merged 3 commits intoapi-platform:masterfrom
dunglas:extract-schema-builder

Conversation

@dunglas
Copy link
Member

@dunglas dunglas 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
Copy link
Member Author

dunglas 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
Copy link
Member Author

dunglas commented Aug 15, 2019

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

@dunglas dunglas force-pushed the extract-schema-builder branch 2 times, most recently from b230729 to a8a8806 Compare August 15, 2019 16:47
@dunglas dunglas marked this pull request as ready for review August 18, 2019 19:39
@dunglas
Copy link
Member Author

dunglas 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 extract-schema-builder branch from cf50ef6 to c421a61 Compare August 19, 2019 08:15
@dunglas dunglas force-pushed the extract-schema-builder branch from c421a61 to c63e635 Compare August 19, 2019 08:49
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.

1 participant