Skip to content
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

swagger UI doesn't work if the annotation Introspector is changed. #54

Closed
dmoses48 opened this issue Apr 4, 2013 · 3 comments
Closed

Comments

@dmoses48
Copy link

dmoses48 commented Apr 4, 2013

If you change out the jacksonAnnotationIntrospector for the JaxbAnnotationIntrospector, or just add the jaxb to the pair, then swagger UI will show your controllers, but not the list of methods under them. See the following for how our spring-mvc webservices are exposed:

<context:component-scan base-package="com.mycompany.controllers"/>


<bean id="jaxbAnnIntrospector" class="com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector" />
<bean id="jacksonAnnIntrospector" class="com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector" />
<bean id="pairIntrospector" class="com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair" >
    <constructor-arg index="0" ref="jacksonAnnIntrospector"/>
    <constructor-arg index="1" ref="jaxbAnnIntrospector"/>
</bean>

<bean id="jacksonObjectMapper" class="com.fasterxml.jackson.databind.ObjectMapper">
    <property name="serializationInclusion" value="NON_NULL"/>
    <property name="annotationIntrospector" ref="pairIntrospector" />
</bean>

<mvc:annotation-driven>
    <mvc:message-converters register-defaults="true">
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">
            <property name="supportedMediaTypes" value="text/plain;charset=UTF-8"/>
        </bean>
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper" ref="jacksonObjectMapper"/>
            <property name="supportedMediaTypes" >
                <list>
                    <value>application/json</value>
                    <value>application/xml</value>
                </list>
            </property>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
@dilipkrish
Copy link
Member

@dmoses48 Which version of swagger-springmvc are you using. I haven't tried using jaxb annotations, but my guess would be that its not using your redefined message converter and using a new instance of ObjectMapper.

@dilipkrish
Copy link
Member

@dmoses48 do you think I can close this issue? Theres already a feature out there that respects jaxb annotations using jackson. Would you mind trying it out and letting me know how it works using the 0.5.0-SNAPSHOT build. You can find examples of config changes here.

@dilipkrish
Copy link
Member

The library now comes with an example schema provider that uses Jackson2. There is extensibility hooks to use an externally configured object mapper. Its not yet released and documentation leaves a lot to be desired but the example project should give you an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants