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

Swagger UI always adds "additionalProp1": {} to the example value #3883

Closed
dunglas opened this issue Dec 5, 2020 · 8 comments
Closed

Swagger UI always adds "additionalProp1": {} to the example value #3883

dunglas opened this issue Dec 5, 2020 · 8 comments

Comments

@dunglas
Copy link
Member

dunglas commented Dec 5, 2020

API Platform version(s) affected: 2.6.0 alpha

Description

image

How to reproduce
Just install the distribution. It does that on any class mapped with API Resource.

Possible Solution

We have no occurrences of additionalProp1 in our code base, but they are occurences in Swagger UI's code base. It maybe caused by our generated JSON Schema (https://github.com/api-platform/core/blob/master/src/JsonSchema/SchemaFactory.php) or by a bug in Swagger UI.

@VeryStrongFingers
Copy link

VeryStrongFingers commented Dec 8, 2020

FYI I am getting this issue too, but with version api-platform/core (v2.5.8)
It was not occurring with v2.5.7

@JenniferSpry
Copy link

JenniferSpry commented Dec 10, 2020

I could not find documentation on why this was added but every schema now has additionalProperties set to true so it would make sense for the GUI to add something. See: cf69423

We got rid of it by setting allow_extra_attributes within the normalizationContext.

/**
 * @ApiResource(
 *     normalizationContext={
 *          "allow_extra_attributes"=false
 *     },
 *     collectionOperations={},
 *     itemOperations={}
 * )
 */

@raress96
Copy link

Having this same problem on api-platform/core (v2.5.8). I guess allow_extra_attribute should be set to false globally or something?Don't even know why this was added.

@dunglas
Copy link
Member Author

dunglas commented Dec 13, 2020

Closed by #3888.

@dunglas dunglas closed this as completed Dec 13, 2020
@MarlonAEC
Copy link

MarlonAEC commented Dec 15, 2020

Hi team! I'm still getting the error, api-platform v2.5.8, I just double-check with a fresh new installation and it is still there the additionalProp1 ... any solution to this?? Cheers!

@alanpoulain
Copy link
Member

alanpoulain commented Dec 15, 2020

Please use the dev version (for now): "api-platform/core": "2.5.x-dev"

@jpmmartin
Copy link

I have the same problem, it is somewhat annoying when providing the documentation of my api to external clients, reading the thread I did not understand which is the correct solution to address, if "allow_extra_attributes" = false which becomes something tedious and repetitive of do or use the dev version which I don't think is advisable for a project that adds new functionalities while it is already in production.

@dunglas
Copy link
Member Author

dunglas commented Dec 28, 2020

@juanpablomorenomartin the fix is to upgrade to the 2.5-dev (which is very stable), as pointed out by @alanpoulain, or to wait for the next tag (probably beginning of January).

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

7 participants