cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mandy Warren <mandys.in...@gmail.com>
Subject Re: JSON schema in WADL
Date Tue, 03 Mar 2015 23:43:51 GMT
Hi Sergey,

Thanks for the fast reply! So I've tried the linkAnyMediaTypeToXmlSchema and that worked fine
but we are trying to move away from XSDs to Json Schema so am very supportive of the jira
you raised!

I tried the externalLinks property and it now shows an @href link but I'd really like to see
it inline.

The closest thing I came to what I wanted was using:

@Description(docuri="classpath:/json.schema") 

which generated the schema inline under "doc" but at the method level - really I want to see
the schemas attached to the request / response as they will each use different schema. It's
almost like I need a variation on the @ElementClass where I could specify the json schema
for request & response.

Great news you support Swagger - I'll trying playing with that too.

I'll also hassle SmartBear about support in SoapUI as your blog suggests!

On 3 Mar 2015, at 22:19, Sergey Beryozkin wrote:

> Hi Mandy
> 
> Thanks for experimenting,
> 
> "schemaLocations" points to resources which are assumed to be XML schemas and these schemas
are read as XML. I've actually created a JIRA few days ago to support inlining JSON schemas
but for now schemaLocations is assumed to point to XML schemas only.
> 
> Use an "externalLinks" property, see
> 
> https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorJsonTest.java;h=cf368062059d21624cab45bd7614c6789c02f41e;hb=HEAD
> 
> Another option is to use WADL XML as usual but set a 'linkAnyMediaTypeToXmlSchema' property,
so you'd see representations of type JSON linked to XML schema elements - which is semantically
not correct but can give a good idea to users what properties a JSON request or response may
have...
> 
> We have also started supporting Swagger - which can be good for describing JSON only
services
> 
> Cheers, Sergey
> 
> On 03/03/15 21:48, Mandy Warren wrote:
>> Hi,
>> 
>> I recently read Sergey's blog (http://sberyozkin.blogspot.co.uk/2011/10/describing-json-services-in-wadl.html​)
about support for JSON Wadls and managed to view a wadl in JSON but am still struggling to
link the JSON schema to the wadl. My spring config looks as follows:-
>> 
>>     <bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
>>         <property name="schemaLocations">
>>             <list>
>>                 <value>classpath:/json.schema</value>
>>             </list>
>>         </property>
>>         <property name="ignoreMessageWriters" value="false"/>
>>         <property name="useJaxbContextForQnames" value="false"/>
>>     </bean>
>> 
>>     <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>     </bean>
>> 
>>    <jaxrs:server name="testResource" address="/v1/">
>>         <jaxrs:serviceBeans>
>>             <bean class="mandy.TestResourceV01" />
>>         </jaxrs:serviceBeans>
>>        <jaxrs:providers>
>>            <ref bean="jsonProvider" />
>>            <ref bean="wadlGenerator" />
>>        </jaxrs:providers>
>>     </jaxrs:server>
>> 
>> </beans>
>> 
>> When I try & access the wadl I get this error:
>> 
>> 21:23:47.048 Could not determine bean name for instance of class org.apache.cxf.bus.managers.ServerRegistryImpl.
>> com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123)
in prolog; expected '<'
>>  at [row,col {unknown-source}]: [1,1]
>>         at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647)
>>         at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2054)
>>         at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
>>         at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1353)
>>         at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1247)
>>         at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1174)
>>         at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1163)
>>         at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1109)
>>         at org.apache.cxf.jaxrs.ext.xml.XMLSource.setBuffering(XMLSource.java:75)
>>         at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.loadSchemasIntoCache(WadlGenerator.java:1770)
>>         at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.setSchemaLocations(WadlGenerator.java:1752)
>> 
>> Any idea what I am missing?
>> 
>> Many thanks
>> 
>> Mandy
>> 
>> 
> 
> 
> -- 
> Sergey Beryozkin
> 
> Talend Community Coders
> http://coders.talend.com/
> 
> Blog: http://sberyozkin.blogspot.com


Mime
View raw message