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
Generated file is not compatible with Swagger specification if method parameter is Object and is used as path parameter #1145
Comments
Granted that spring supports this, but doesn't it seem weird that we'd model an object that is represented as a string in the path? This for sure has a couple of work arounds
Let me know if those work for you. I want to be careful not to introduce branching logic for these exception cases that adds complexity to the library for the 0.1% of the people using this library in this way. |
Hi Dilip, We model
Such modeling is also used for example in Mapping from Using implict annotations also works but this is a lot of manual work. I see some differences in generated JSON: body paramater:
path parameter:
After applying workarounds you described JSON is:
and:
so there are some differences in the code already regarding parameter type if parameter is path parameter. For body parameter we have I understand your consideration about code complexity and branching so please do not make any modifications now. We are considering to use SpringFox in our project but we are not sure we will use it. For now we have only a discussion about that. |
@tjuchniewicz The use case seems reasonable, I'll make this a feature request. However, (without any substantiative proof :)) I suspect that you'll need to adjust the constructors and accessors and mutators in just the right way in order reuse the |
Yes, it is needed to make |
When we use Object as method parameter and path parameter in the same time SpringFox generates file that is not compatible with Swagger specification.
From this code:
public CommandStatus method(@PathVariable("myObject") MyObject myObject);
SpringFox generates Swagger definition equivalent to adding this annotation:
the key is
dataType = "object"
which is not compatible with Swagger specification. Objects can't be used as path parameters.In this case SpringFox should generate definition equivalent to this annotation:
It would be consistent with Spring MVC. The same behaviour is implemented in Spring. Every object used as path parameter is mapped to string in URL path by default. Such object must define
Object(String)
constructor to make it work.The text was updated successfully, but these errors were encountered: