Skip to content

fix(openapi): do not use jsonld schema for all media types #4247

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

Merged
merged 5 commits into from
May 6, 2021
Merged

fix(openapi): do not use jsonld schema for all media types #4247

merged 5 commits into from
May 6, 2021

Conversation

guilliamxavier
Copy link
Contributor

Q A
Branch? 2.6
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #4215
License MIT
Doc PR

Follows #4213

Comment on lines +197 to +207
And the JSON node "paths./dummies.get.responses.200.content.application/json" should be equal to:
"""
{
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Dummy"
}
}
}
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This step was failing (the schema was the same as jsonld above)

$schema = $schema ?? new Schema();
$schema = null !== $schema ? clone $schema : new Schema();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix

Copy link
Member

Choose a reason for hiding this comment

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

$schema ? clone $schema : new Schema() would work as well right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I missed this comment. Thanks for proposing a suggestion, I've just accepted it

Comment on lines -257 to -259
$schema = new Schema('openapi');
$schema->setDefinitions($schemas);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was added by #4213, not needed anymore

$this->jsonSchemaFactory->buildSchema($resourceClass, $format, $type, $operationType, $operationName, $schema, $serializerContext, $forceCollection);

return $schema;
return $this->jsonSchemaFactory->buildSchema($resourceClass, $format, $type, $operationType, $operationName, $schema, $serializerContext, $forceCollection);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a consequence of the fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@soyuka: Refs #4215 (comment). I have added a note to the changelog entry

@guilliamxavier guilliamxavier changed the title Fix OpenAPI using jsonld for all media types Fix OpenAPI uses jsonld for all media types Apr 26, 2021
Copy link
Member

@alanpoulain alanpoulain left a comment

Choose a reason for hiding this comment

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

LGTM

@alanpoulain alanpoulain requested a review from soyuka April 27, 2021 13:37
@guilliamxavier guilliamxavier changed the title Fix OpenAPI uses jsonld for all media types fix(openapi): do not use jsonld schema for all media types Apr 30, 2021
Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
@guilliamxavier guilliamxavier requested a review from soyuka April 30, 2021 13:38
Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
@alanpoulain alanpoulain merged commit 7d99161 into api-platform:2.6 May 6, 2021
@alanpoulain
Copy link
Member

Thank you @guilliamxavier.

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.

3 participants