-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[SPRING] Bug generating GET-Requests because of empty consumes attributes #7734
Comments
Would it work if the generated code would look like this?
|
Yes, that code would work. I did a bit of digging yesterday. I think the following behaviour would be nice: get:
produces:
- application/json leads to @RequestMapping(value = "/applications/{stage}",
produces = "application/json",
method = RequestMethod.GET) If I leave out the @RequestMapping(value = "/applications/{stage}",
method = RequestMethod.GET) or @RequestMapping(value = "/applications/{stage}",
produces = {},
method = RequestMethod.GET) The reasoning behind this: If you look at the So basically, if I don't define it in my yaml, I want the Spring default. Is that reasonable? |
I can not tell (I do not know the Spring framework and I am also not a swagger expert). But I can tell you how you can test it locally: I assume you are using Swagger v2 ( The codegen class corresponding to I think the position to change is arround Line 97 in api.mustache. Current implementation:
(1) to perform such checks, I would add following line before
(2) check it like this:
(3)
If this works, you should propose a pull request. Please test also the other case with multiple content types If something is not clear enough, please continue the discussion. |
Thank you, @jmini. I think your suggestion is spot on. I am still testing, but it looks very promising. |
Description
I am trying to generate a Java Spring API from yaml using mvn and the swagger-codegen-maven-plugin. More specifically I am trying to model a GET Request. The generated code looks like this:
Please note the
consumes = ""
, which will prevent Springs Application Context from starting (using Spring Boot 2.0.0.RC2) and will produce a stacktraceSwagger-codegen version
Affected: swagger-codegen 2.3.1
This is a regression from 2.2.3, where it works.
SpringBoot 2.0.0.RC2
Swagger declaration file content or url
YAML to reproduce
Command line used for generation
I am building with maven, so the swagger config looks like this:
Steps to reproduce
Build with mvn, try to start the application with
mvn spring-boot:run
. Application startup will fail.Suggest a fix/enhancement
For HTTP GET there should not be a
consume
attribute present.The text was updated successfully, but these errors were encountered: