[英]Enhancing wadl in apache CXF with fasterxml.jackson serializer
I have a rest app using fasterxml jackson for serialization. 我有一个使用fastxml jackson进行序列化的rest应用程序。
I wanted to enhance the wadl to show the model fields inside the representation tag, such as 我想增强wadl以显示制图表达标签内的模型字段,例如
<representation mediaType="application/json">
<doc>...</doc>
<param name="myField" type="xs:string"/>
...
</representation>
instead of the vanilla description of: 而不是原始的描述:
<representation mediaType="application/json">
<doc>...</doc>
</representation>
I thought adding a bean for WadlGeneration was all I needed to do... 我以为WadlGeneration添加一个bean是我要做的全部...
<bean id="jacksonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider">
<constructor-arg><ref bean="customObjectMapper"/></constructor-arg>
</bean>
<bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
<property name="linkJsonToXmlSchema" value="true" />
<property name="supportCollections" value="true"/>
<property name="ignoreMessageWriters" value="false"/>
<property name="useJaxbContextForQnames" value="false"/>
</bean>
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
...
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml"/>
<entry key="json" value="application/json"/>
</jaxrs:extensionMappings>
<jaxrs:providers>
<ref bean="jacksonProvider" />
<ref bean="wadlGenerator" />
</jaxrs:providers>
</jaxrs:server>
.. but apparently there is more to do. ..但显然还有更多工作要做。 I have seen examples in jaxb and codehaus jackson, but any ideas on how to make this work with fasterxml jackson?
我已经在jaxb和codehaus jackson中看到了示例,但是关于如何使fastxml与jackson一起工作的任何想法?
Appears the solution was to include @xmlrootelement on each of my models. 看来解决方案是在每个模型上都包含@xmlrootelement。 Then I used the doc generator: http://enunciate.codehaus.org/index.html
然后,我使用了文档生成器: http : //enunciate.codehaus.org/index.html
As long as my models have the element defined, it de-serializes as expected. 只要我的模型具有定义的元素,它就会按预期反序列化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.