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 documentation does not pick up the right model class in spite of using the version of swagger[2.2.4] #4038

Closed
3 tasks
swatikamath opened this issue Nov 18, 2022 · 2 comments
Labels

Comments

@swatikamath
Copy link

swatikamath commented Nov 18, 2022

We've gone through articles that we found to ensure that this is not a duplicate issue. The swagger documentation does not pick up the correct version of the model class if the model is present in other referred micro services.

  • What version of the library are you using? Is it the latest version? The latest released version is [ ![Download]
    We are using the following JAR's with version 1.6.9, but the issue is occurring even with the version 1.6.12.
org.springdoc springdoc-openapi-webflux-core 1.6.9, org.springdoc springdoc-openapi-webflux-ui 1.6.9, org.springdoc springdoc-openapi-ui 1.6.9, What kind of issue is this? We have a model class that is referred in 3 other services that we have. When we check the documentation in swagger, the model definition that shows up, refers to the model of one of the referred service, instead of the service where it is defined. This issue does not occur for all models with the same name, but its occurring for some model documentations for certain services. The same model is causing a problem in all other services where it is referred in the swagger documentation.
  • Question. Is this a question about how to do a certain thing?
    No, it's a defect that is occurring in our applications.

  • Bug report.
    REST API specification:
    @GetMapping(value = "/personal/education",
    produces = {APPLICATION_STREAM_JSON_VALUE})
    Mono<Personal.Education> education(@PathVariable(name = "context") final String profileContext, final String id);

The documentation that comes up for this API is incorrect and as shown below.
{
"degree": {
"code": "string",
"description": "string"
},
"major": {
"code": "string",
"description": "string"
},
"school": {
"code": "string",
"description": "string"
}
}

The expected documentation for Personal.Education object is:
{
"meta": {
"empty": true,
"additionalProp1": [
{}
],
"additionalProp2": [
{}
],
"additionalProp3": [
{}
]
},
"educations": [
{
"externalData": true,
"education": "string"
}
]
}

Personal.java has the following snippet for the Education object.
@DaTa
@builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class Personal {
..
private Education education;
....

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class Education {
    private MetaData meta;

    private List<EducationExt> educations;
}

}

For now, we have a workaround by adding the following annotation of @Schema.
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "success", content = {@content(
mediaType = "application/json",
schema = @Schema(implementation = Personal.Education.class))})}

Kindly help us to resolve this issue.

@stale
Copy link

stale bot commented Apr 26, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 26, 2023
@stale
Copy link

stale bot commented May 20, 2023

This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue.

@stale stale bot closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant