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

Incorrect generation of response model reference #3646

Closed
meshuga opened this issue Nov 25, 2020 · 2 comments
Closed

Incorrect generation of response model reference #3646

meshuga opened this issue Nov 25, 2020 · 2 comments
Labels

Comments

@meshuga
Copy link

meshuga commented Nov 25, 2020

Library used: io.springfox:springfox-boot-starter:3.0.0

I'm trying to define method response models in Spring but am facing an error where Swagger 2/OpenAPI 3 documentation provides the following JSON:

   "responses":{
      "200":{
         "description":"OK",
         "content":{
            "application/json":{
               "schema":{
                  "$ref":"Error-ModelName{namespace='aaaa', name='XXXX'}"
               }
            }
         }
      },
      ...
   }

Class model (am using Kotlin):

@RestController
@RequestMapping("/sth", consumes = [APPLICATION_JSON_VALUE], produces = [APPLICATION_JSON_VALUE])
class Controller() {
    @PostMapping
    @ApiResponses(
        ApiResponse(responseCode = "200", description = "created",
            content = [Content(mediaType = APPLICATION_JSON_VALUE, schema = 
            Schema(implementation = XXXX::class))]),
    )
    @ApiOperation("something")
    suspend fun initiate(
        @Valid @RequestBody request: Request
    ): XXXX {
        ....
    }
    ....
}

Current workaround is to add the model manually:

    @Bean
    fun api(typeResolver: TypeResolver): Docket {
        return Docket(SWAGGER_2)
            ....
            .additionalModels(typeResolver.resolve(XXXX::class.java))
    }

Related issue: #3348
Related SO (not raised by me): https://stackoverflow.com/questions/63662483/could-not-resolve-pointer-definitions-error-modelname

@stale
Copy link

stale bot commented Feb 23, 2021

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 Feb 23, 2021
@stale
Copy link

stale bot commented Mar 9, 2021

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 Mar 9, 2021
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