You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
The text was updated successfully, but these errors were encountered:
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
#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
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.
The text was updated successfully, but these errors were encountered: