Skip to content

Feature: Please detect ModelAndView as text/html content #428

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

Closed
coding-jj opened this issue Feb 14, 2020 · 1 comment
Closed

Feature: Please detect ModelAndView as text/html content #428

coding-jj opened this issue Feb 14, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@coding-jj
Copy link

Is your feature request related to a problem? Please describe.

  • No OpenApi Endpoint is rendered for return type org.springframework.web.servlet.ModelAndView (see example at the end)

Describe the solution you'd like

  • springdoc-openapi should detect ModelAndView
  • Return OpenApi Document like (mind the "type": "string"):
"responses": {
  "200": {
    "description": "default response",
    "content": {
      "text/html": {
        "schema": {
          "type": "string"
        }
      }
    }
  }
}

Describe alternatives you've considered

Workaround return Object. But this will not produce a correct return type.

@Operation(summary = "Get Status")
@GetMapping(value = "/status", produces = MediaType.TEXT_HTML_VALUE)
public Object getStatus()

OpenApi Response should be "type": "string"

"responses": {
  "200": {
    "description": "default response",
    "content": {
      "text/html": {
        "schema": {
          "type": "object"
        }
      }
    }
  }
}

Additional context

Example:

@Operation(summary = "Get Status")
@GetMapping(value = "/status", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getStatus()
@bnasslahsen
Copy link
Collaborator

Hi @notes-jj,

By default ModelAndView is ignored in springdoc-openapi.
With the next release: v1.2.31, you will be able to display RestControllers that use ModelAndView as well.
For that, you will need to define the following property:

springdoc.model-and-view-allowed=true

If you need to map ModelAndView to a another more convinient type (for example Object), you can just add the following declaration, in any static block:

AdditionalModelsConverter.replaceWithSchema(ModelAndView .class, new ObjectSchema());

You can hava a look at SpringDocApp89Test for more details.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants