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

SwaggerUI shows error: Unable to render this definition #2686

Closed
pauljura opened this issue Apr 9, 2024 · 1 comment
Closed

SwaggerUI shows error: Unable to render this definition #2686

pauljura opened this issue Apr 9, 2024 · 1 comment

Comments

@pauljura
Copy link

pauljura commented Apr 9, 2024

API Platform version(s) affected: 3.2.20

Description
I just upgraded a project that was using API Platform 3.1.17 to the latest release 3.2.20 and when I try to view the Swagger docs I get the following error:

Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).

I can view the docs using ReDoc and download the swagger file, which I can see now has the following key; "openapi": "3.1.0" while my previous version had: "openapi": "3.0.0"

How to reproduce

Update to 3.2.20 and look at Swagger docs.

Possible Solution

I already have a decorator in my project to override the spec so it was easy for me to override the version from "3.1.0" to "3.0.0" and that makes the Swagger UI work with no further changes.

I also found the OpenApi class in ApiPlatform\OpenApi and if I change the VERSION constant to be "3.0.0" that also makes it work.

In fact, looking at my old version, that OpenApi class had the following code:

    // We're actually supporting 3.1 but swagger ui has a version constraint
    // public const VERSION = '3.1.0';
    public const VERSION = '3.0.0';

Looks like someone removed that and set the version to "3.1.0" and now it's broken. Was there some other change that should have been done to make all this work?

It seems that the SwaggerUI really needs the version to be in the form "3.0.n" and will not accept "3.1.0"

I'm actually surprised nobody else has reported this. Is it just me? Am I missing something?

Additional Context

image

@pauljura
Copy link
Author

See api-platform/core#6339

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

No branches or pull requests

1 participant