Closed stundzig closed 11 years ago
Hi Steffen, these are great changes. I didn't include the change you made to DocumentationParameterParser because I'm not sure we should be setting the return type of the method as the data type of the parameter. That would make more sense if we were dealing with ResponseBody. Is there something I missed? Thanks!
Hi,
on ResponseBody Annotation you should set the simplename of the returnType. Then the swagger ui searches for the appropriate type and prints the JSon Schema in the UI. Thats a great feature. On the RequestHeader and RequestParam these datatype should be one of the swagger primitives.
regards
Am 20.03.13 01:02, schrieb Will Kennedy:
Hi Steffen, these are great changes. I didn't include the change you made to DocumentationParameterParser because I'm not sure we should be setting the return type of the method as the data type of the parameter. That would make more sense if we were dealing with ResponseBody. Is there something I missed? Thanks!
— Reply to this email directly or view it on GitHub https://github.com/wkennedy/swagger4spring-web/pull/3#issuecomment-15151396.
Hi Will,
I've a very urgent patch for the ApiDocumentationController.
@SuppressWarnings("unused")
public String getBasePath() {
if (basePath == null || basePath.isEmpty()) {
//If no base path was specified, attempt to get the base
path from the request URL HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest(); if(request != null) { basePath = request.getRequestURL().toString(); // cut to the start of this request mapping basePath = basePath.substring(0, basePath.indexOf("/api") + 1); } } return basePath; }
I cut the base path before the start of the /api-url of this Controller. This I must do, because my servlet matches on /* so servletpath is "". And also I dont know exactly, if my app is deployed on / or on a different location.
So I can't set the base path on the controller.
Could you change this? The difference is in
basePath = basePath.substring(0, basePath.indexOf("/api") + 1);
Or do you have any other ideas?
Regards
Am 20.03.13 01:02, schrieb Will Kennedy:
Hi Steffen, these are great changes. I didn't include the change you made to DocumentationParameterParser because I'm not sure we should be setting the return type of the method as the data type of the parameter. That would make more sense if we were dealing with ResponseBody. Is there something I missed? Thanks!
— Reply to this email directly or view it on GitHub https://github.com/wkennedy/swagger4spring-web/pull/3#issuecomment-15151396.
Steffen Stundzig Consultant
Telefon: +49 (0) 341 231 0183 21 Telefax: +49 (0) 341 231 0183 11 Mobil: +49 (0) 171 300 1480
http://itemis.de http://twitter.com/itemis steffen.stundzig@itemis.de https://xing.com/profile/Steffen_Stundzig
itemis AG Niederlassung Leipzig Dohnanyistrasse 15 04103 Leipzig
Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan Grollmann, Michael Neuhaus
Are you currently defining the ApiDocumentationController bean in your servlet context? For your case, I would recommend extending the ApiDocumentationController instead and possibly overriding getBasePath and making the change you need. The reason I don't want to put
basePath = basePath.substring(0, basePath.indexOf("/api") + 1);
in the method is because if a person extends ApiDocumentationController and overrides the RequestMapping to something else "/api" may no longer be relevant. For example, I might implement the code like this
@Controller
@RequestMapping(value = "/documentation")
public class ExampleDocumentationController extends ApiDocumentationController {
...
@Override
public String getBasePath() {
if (basePath == null || basePath.isEmpty()) {
//If no base path was specified, attempt to get the base path from the request URL
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
if(request != null) {
basePath = request.getRequestURL().toString();
// cut to the start of this request mapping
basePath = basePath.substring(0, basePath.indexOf("/api") + 1);
}
}
return basePath;
}
}
...
}
Would that work for you?
Hi,
in another place in my rest api, I need the basepath too, so I can use this basePath-property in my dispatcherServlet.xml.
Currently I'm working on spring parameter replacement in Swagger annotations. Do you have any thoughts on that too?
And also, I would like to annotate my @XmlRootElement tagged classes, to better support swagger JSonSchema. It works for all primitives, but not for Collection types like:
@XmlRootElement(name = "orderRequest")
@XmlAccessorType(XmlAccessType.FIELD)
public class OrderRequestDTO {
@XmlElementWrapper
@XmlElement(name = "order")
private Collection
The JSon-Schema contains the DTO and the primitives, but not the orders-Array.
Do you have some documentation or code samples, what I should configure too?
Thank you for any help.
Regards Steffen...
Am 20.03.13 22:45, schrieb Will Kennedy:
Are you currently defining the ApiDocumentationController bean in your servlet context? For your case, I would recommend extending the ApiDocumentationController instead and possibly overriding getBasePath and making the change you need. The reason I don't want to put
basePath = basePath.substring(0, basePath.indexOf("/api") + 1); in the method is because if a person extends ApiDocumentationController and overrides the RequestMapping to something else "/api" may no longer be relevant. For example, I might implement the code like this
@Controller @RequestMapping(value = "/documentation") public class ExampleDocumentationController extends ApiDocumentationController { ... @Override public String getBasePath() { if (basePath == null basePath.isEmpty()) { //If no base path was specified, attempt to get the base path from the request URL HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest(); if(request != null) { basePath = request.getRequestURL().toString(); // cut to the start of this request mapping basePath = basePath.substring(0, basePath.indexOf("/api") + 1); } } return basePath; } } ... } Would that work for you?
— Reply to this email directly or view it on GitHub https://github.com/wkennedy/swagger4spring-web/pull/3#issuecomment-15205648.
Steffen Stundzig Consultant
Telefon: +49 (0) 341 231 0183 21 Telefax: +49 (0) 341 231 0183 11 Mobil: +49 (0) 171 300 1480
http://itemis.de http://twitter.com/itemis steffen.stundzig@itemis.de https://xing.com/profile/Steffen_Stundzig
itemis AG Niederlassung Leipzig Dohnanyistrasse 15 04103 Leipzig
Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan Grollmann, Michael Neuhaus
Hi Steffen,
Do you have more detail on what you mean by "spring parameter replacement in Swagger annotations"?
As for the JSON Schema and Collection types, I believe the problem there is type erasure with Java generics. Once the class is compiled, your Collection just contains Objects and you have no real way of knowing what's in there. If you used an array instead, it would be possible (OrderRequestEntityDTO[] orders;).
Hi,
sry, but i'm not the advanced git user. Could you please remove/ignore my changes in pom.xml and in TestPojo?
Regards