cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Fiala (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-6965) CXF Swagger2Feature does not correctly support QueryParam("") and DataHandler
Date Mon, 11 Jul 2016 07:08:11 GMT

    [ https://issues.apache.org/jira/browse/CXF-6965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15369248#comment-15369248
] 

J. Fiala edited comment on CXF-6965 at 7/11/16 7:08 AM:
--------------------------------------------------------

I have also some comments regarding the WadlGenerator, maybe you can open a separate issue
for these?

1. No bean-validation-support.
2. Annotations in the interface are not parsed
3. Example for DataHandler not supported in WADL
4. @Description currently generates tags <doc></doc>

h2. Issues for the WadlGenerator:

h3. 1. No bean-validation-support.
I added this PR for bean-validation-support for query parameters:
https://github.com/apache/cxf/pull/146

This also adds the required-flag for params by supporting @NotNull.
(see related question here: http://stackoverflow.com/questions/13968261/required-queryparam-in-jax-rs-and-what-to-do-in-their-absence).

For adding bean-validation-support to the complex types the JAXB processing / schema has to
be parsed/filtered.

The Java to schema mappings seems to be done here in WadlGenerator.java, line 1541:
{code}
 for (DOMResult r : JAXBUtils.generateJaxbSchemas(context, CastUtils.cast(Collections.emptyMap(),
                                                                                     String.class,
                                                                                     DOMResult.class)))
{
{code}

Am I correct in assuming we need a JAXB adapter which picks up the beanvalidation-annotations?

https://docs.oracle.com/cd/E19316-01/819-3669/bnbdf/index.html
So it seems we need to prepare the proper XmlAdapters (https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html)
to generate the necessary restrictions in the schema. However, it would also be nice to also
add proper SimpleTypes and reference them from the complexTypes (e.g. simpleType string_50
for a string with a maximum of 50).


h3. 2. Annotations in the interface are not parsed
(e.g. @Description, but also true for the bean-validation-annotation scanning for QueryParam
(see 1.))


h3. 3. Example for DataHandler not supported in WADL:

{code}
@Consumes({ MediaType.MULTIPART_FORM_DATA })
	@Produces({ MediaType.APPLICATION_JSON })
	@POST
	@Path("/helloMultipart")
	public void helloMultipart(@Multipart(value= "payload" , type=MediaType.APPLICATION_OCTET_STREAM)
DataHandler handler) {

	}
{code}

is rendered in WADL (WRONG):
{code}
<resource path="/helloMultipart"><method name="POST"><request><representation
mediaType="application/x-www-form-urlencoded"/></request>
{code}

this would be the basic correct WADL rendering:
{code}
<resource path="/helloMultipart"><method name="POST"><request><representation
mediaType="multipart/form-data"/></request>
{code}

Which will become after wadl2java:
{code}
postHelloMultipart(MultipartBody body);
{code}

Of course it would be nice to have all the Multipart rendered correctly in WADL as well.

4.) @Description currently generates tags <doc></doc>:
These are invalid for schemas.
The correct tags are <xs:annotation><xs:documentation>...</xs:documentation></xs:annotation>
This should be corrected.



was (Author: jfx):
I have also some comments regarding the WadlGenerator, maybe you can open a separate issue
for these?

1. No bean-validation-support.
2. Annotations in the interface are not parsed
3. Example for DataHandler not supported in WADL
4. @Description currently generates tags <doc></doc>

h2. Issues for the WadlGenerator:

h3. 1. No bean-validation-support.
I added this PR for bean-validation-support for query parameters:
https://github.com/apache/cxf/pull/146

This also adds the required-flag for params by supporting @NotNull.
(see related question here: http://stackoverflow.com/questions/13968261/required-queryparam-in-jax-rs-and-what-to-do-in-their-absence).

For adding bean-validation-support to the complex types the JAXB processing / schema has to
be parsed/filtered.

h3. 2. Annotations in the interface are not parsed
(e.g. @Description, but also true for the bean-validation-annotation scanning for QueryParam
(see 1.))


h3. 3. Example for DataHandler not supported in WADL:

{code}
@Consumes({ MediaType.MULTIPART_FORM_DATA })
	@Produces({ MediaType.APPLICATION_JSON })
	@POST
	@Path("/helloMultipart")
	public void helloMultipart(@Multipart(value= "payload" , type=MediaType.APPLICATION_OCTET_STREAM)
DataHandler handler) {

	}
{code}

is rendered in WADL (WRONG):
{code}
<resource path="/helloMultipart"><method name="POST"><request><representation
mediaType="application/x-www-form-urlencoded"/></request>
{code}

this would be the basic correct WADL rendering:
{code}
<resource path="/helloMultipart"><method name="POST"><request><representation
mediaType="multipart/form-data"/></request>
{code}

Which will become after wadl2java:
{code}
postHelloMultipart(MultipartBody body);
{code}

Of course it would be nice to have all the Multipart rendered correctly in WADL as well.

4.) @Description currently generates tags <doc></doc>:
These are invalid for schemas.
The correct tags are <xs:annotation><xs:documentation>...</xs:documentation></xs:annotation>
This should be corrected.


> CXF Swagger2Feature does not correctly support QueryParam("") and DataHandler
> -----------------------------------------------------------------------------
>
>                 Key: CXF-6965
>                 URL: https://issues.apache.org/jira/browse/CXF-6965
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>            Reporter: Sergey Beryozkin
>            Priority: Minor
>             Fix For: 3.2.0, 3.1.8
>
>
> See https://github.com/swagger-api/swagger-codegen/issues/2017#issuecomment-230426728



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message