-
-
Notifications
You must be signed in to change notification settings - Fork 874
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
BC Support for OpenApi v3.0.x #5978
Comments
It's been a while that this is out, Microsoft is an OpenAPI Member maybe we can ask them to update? For now you can fix this with a custom normalizer and remove what's not supported. If you do so I'll be glad to accept a contribution. |
Thanks for the quick response @soyuka. I have reached out to Microsoft support to ask about updating and limitations and am also working on custom normalization for my project. If I come up with something useful / reusable I'll post here. For awareness anyone anyone else facing the same issue, they are throwing errors for nullable types and they don't like the "properties": {
"id": {
"type": [ // Generates an error in APIM
"integer",
"null"
]
},
"type": {
"owl:maxCardinality": 1, // Generates an error in APIM
"type": "number",
"example": 1,
"nullable": false
},
.... |
aside from Microsoft there are still a lot of tools out there struggling to support the v3.1 specification. We're using openapi-generator (https://github.com/OpenAPITools/openapi-generator/) for automatic generation of PHP client-code - currently not supporting v3.1 (OpenAPITools/openapi-generator#9083). So, if there's any chance api plaform can be configured to explicitly change between v3.0 and v3.1, this would be of great help. |
I think that https://github.com/api-platform/schema-generator supports it no?
Damn... I wish they had not refactored the whole parser and instead just update the old one... For the type issues above you can override I don't have many ideas, or we create a normalizer that tries to remove non-compatible stuff (a pain to maintain). I'm open to suggestions, is there anything else then types regarding Microsoft? |
can you try my patch? |
@soyuka The logic looks good, but it doesn't seem to be persisting the changes to the output. The output for these types are still coming out the same for me. Perhaps getting overridden somewhere else later in the process? I came to a similar solution in my OpenApiFactory decorator. However, I used the foreach ($schemas as $name => $component) {
foreach ($component['properties'] ?? [] as $property => $value) {
if (is_array($value['type'] ?? false)) {
foreach ($value['type'] as $type) {
$schemas[$name]['properties'][$property]['anyOf'][] = ['type' => $type];
}
unset($schemas[$name]['properties'][$property]['type']);
}
unset($value['owl:maxCardinality']);
}
} Some other things I noticed. The change is giving an error when running from CLI and sending a request to the Docs page without the With the CLI, passing in {
"@context": "\/contexts\/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Warning: Undefined array key \u0022spec_version\u0022",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "\/srv\/app\/vendor\/api-platform\/core\/src\/OpenApi\/Serializer\/LegacyOpenApiNormalizer.php",
"line": 34,
"args": []
},
{
"namespace": "ApiPlatform\\OpenApi\\Serializer",
"short_class": "LegacyOpenApiNormalizer",
"class": "ApiPlatform\\OpenApi\\Serializer\\LegacyOpenApiNormalizer",
"type": "-\u003E",
"function": "normalize",
"file": "\/srv\/app\/vendor\/symfony\/serializer\/Debug\/TraceableNormalizer.php",
"line": 58,
"args": [
[
"object",
"ApiPlatform\\OpenApi\\OpenApi"
],
[
"string",
"json"
],
[
"array",
{
"debug_trace_id": [
"string",
"657724d9464ec"
]
}
]
]
},
...
]
} |
indeed I added this only to the DocumentationAction. You could've proposed a patch your code is pretty similar to what I have, may I add this to my PR? I'll add some test anyways thanks for the feedback! |
Yes @soyuka please feel free to use those changes. Thank you. You guys and API Platform are awesome :) |
fixes api-platform#5978 feat: add missing spec_version params from command to normalizer fix: improve legacy open api normalizer feat: adding spec version to entrypoint action fix(openapi): code style fix(openapi): wrong entrypoint action changed fix(openapi): remove unused use fix(openapi): fix suggestion tests(openapi): fix documentation action test fix(openapi): check if spec_version exist before compare fix(openapi): improve check spec_version fix(openapi): fix existing tests
fixes api-platform#5978 feat: add missing spec_version params from command to normalizer fix: improve legacy open api normalizer feat: adding spec version to entrypoint action fix(openapi): code style fix(openapi): wrong entrypoint action changed fix(openapi): remove unused use fix(openapi): fix suggestion tests(openapi): fix documentation action test fix(openapi): check if spec_version exist before compare fix(openapi): improve check spec_version fix(openapi): fix existing tests
fixes #5978 Co-authored-by: soyuka <[email protected]>
will be released by the end of the week |
Description
As of API Platform 3.2+, OpenApi output with
spec_version=3
defaults to OpenApi 3.1.xSome third party systems do not support import with OpenAPI 3.1 spec. (Currently Azure APIM does not accept OpenAPI generated from API Platform).
Asking for the
api:openapi:export
command to supportspec_version=3.0
andspec_version=3.1
The text was updated successfully, but these errors were encountered: