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

If two diff model class has same value for "@JsonRootName" annotation,if i am using these two model for req and resp of any api method then ,It overriding the one class to another randomly and as a result showing the same example value for req and resp. #3286

Closed
yashodhan1211 opened this issue Sep 9, 2019 · 1 comment

Comments

@yashodhan1211
Copy link

I have just encountered this behaviour and was really suprised because I would assume that this would be a serious issue. For example I have one User model and have multiple request and response classes for multiple operations with User - each containing only a subset of User's attributes.

For example I have class CreateUserRequest (in one package) annotated with @JsonRootName(value = "user") and another class UpdateUsersStateRequest (may be even in the same package) again with annotation @JsonRootName(value = "user"). Swagger definition has only one of those definitions and ignoring others so basically most of the generated examples which I see in swagger UI are wrong.

I would assume that swagger would have different definition for each REST method, am I missing something? It is extremely important to be able to define same object with different attributes in different API methods.

@yashodhan1211 yashodhan1211 changed the title If two diff model class has same value for "@JsonRootName" annotation,if i am using these two for req and resp of any api method then ,It overriding the one class to another randomly and as a result showing the same example value for req and resp. If two diff model class has same value for "@JsonRootName" annotation,if i am using these two model for req and resp of any api method then ,It overriding the one class to another randomly and as a result showing the same example value for req and resp. Sep 9, 2019
frantuma added a commit that referenced this issue Sep 18, 2019
…tName-v1

fix #3286 - prioritize schema name resolving by `ApiModel.value`
@frantuma
Copy link
Member

#3292 addresses this issue, by prioritizing name resolving by ApiModel annotation; in a case similar to the one described in this ticket the ApiModel annotation value is used to resolve the name, allowing to distinguish scheams with the same JsonRootName.

Closing ticket, please reopen if you're still experiencing issues

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

2 participants