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

Missing @RequestParam on a boolean parameter causes Swagger page to not render that controller, and all controllers alphabetically after #1325

Closed
Thunderforge opened this issue May 24, 2016 · 5 comments

Comments

@Thunderforge
Copy link
Contributor

Thunderforge commented May 24, 2016

I have an @RestController that has a single endpoint:

//Endpoint within status-controller
@RequestMapping(value = "ping", method = {RequestMethod.HEAD, RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE)
public PingResponse ping(boolean deep) {
    [...]
}

Note that this is missing an @RequestParam on the boolean parameter. When Springfox tries to render this, the output appears like this:

swagger failure edited

Note that the top of the page has the message "Finished Loading Resource Information. Rendering Swagger UI..." and there is an error in the console. The full error is as follows:

swagger-ui.min.js:10 Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
(anonymous function) @ swagger-ui.min.js:10
Handlebars.templates.param_list.Handlebars.template.main @ swagger-ui.min.js:1
e @ handlebars-2.0.0.js:27
SwaggerUi.Views.ParameterView.Backbone.View.extend.render @ swagger-ui.min.js:10
SwaggerUi.Views.OperationView.Backbone.View.extend.addParameter @ swagger-ui.min.js:10
SwaggerUi.Views.OperationView.Backbone.View.extend.render @ swagger-ui.min.js:10
SwaggerUi.Views.ResourceView.Backbone.View.extend.addOperation @ swagger-ui.min.js:11
SwaggerUi.Views.ResourceView.Backbone.View.extend.render @ swagger-ui.min.js:11
SwaggerUi.Views.MainView.Backbone.View.extend.addResource @ swagger-ui.min.js:10
SwaggerUi.Views.MainView.Backbone.View.extend.render @ swagger-ui.min.js:10
window.SwaggerUi.Backbone.Router.extend.render @ swagger-ui.min.js:10
options.success @ swagger-ui.min.js:10
y.buildFromSpec @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
a.finish @ swagger-ui.min.js:3
(anonymous function) @ swagger-ui.min.js:2
a.resolve @ swagger-ui.min.js:2
n.on.response @ swagger-ui.min.js:2
l @ swagger-ui.min.js:2
e.on.response @ swagger-ui.min.js:2
(anonymous function) @ swagger-ui.min.js:2
f.callback @ swagger-ui.min.js:10
(anonymous function) @ swagger-ui.min.js:9
r.emit @ swagger-ui.min.js:10
n.onreadystatechange @ swagger-ui.min.js:10

Also in this particular example, there are four controllers: cluster-controller, message-controller, status-controller, and test-controller. The endpoint above is inside of status-controller and it does not appear on the page. However, the next controller alphabetically, test-controller, also does not appear, with no indication about the source of the problem or that other controllers are prevented from displaying.

Adding @RequestParam to the endpoint parameter does solve this problem, but I believe that the current behavior should be addressed. I expect that either:

  • Swagger UI renders the endpoint properly, despite it missing @RequestParam (since it is an endpoint that is valid in Spring)
  • A more helpful error message appears in either my Java console or the Swagger UI to indicate that I need to add @RequestParam to my boolean parameter

Also, it would be really wonderful if a failure in one controller only prevents that one controller from appearing, rather than preventing all controllers alphabetically afterwards from appearing as well.

@dilipkrish
Copy link
Member

@Thunderforge thanks for the detailed issue. It would be useful to also know what your swagger api-docs looks like.. the relevant snippet at least. You can find it @ ...../v2/api-docs

@dilipkrish
Copy link
Member

@Thunderforge Did a little bit of research sending in a boolean in the body is totally valid. So its a bug in swagger-ui and you may want to report it there. Specifically the following parameter should be supported.

"parameters": [

    {
        "in": "body",
        "name": "someBoolean",
        "description": "someBoolean",
        "required": false,
        "schema": {
            "type": "boolean"
        }
    }

],

@Thunderforge
Copy link
Contributor Author

Thunderforge commented May 29, 2016

Thanks for duplicating that. Where do I go to report that buggy swagger-ui? I am new to all this.

Also, do you still need my swagger api-docs? I was having trouble locating them. We are creating a war and I don't see an api-docs folder aside from inside to springfox jar itself.

@dilipkrish
Copy link
Member

@Thunderforge you'd have to report it here

Don't worry about the api-docs. Also FYI its generated on the fly so you won't find it anywhere on disk

@Thunderforge
Copy link
Contributor Author

I have reported this issue to Swagger-ui. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants