Code Monkey home page Code Monkey logo

Comments (7)

WeipingGuo avatar WeipingGuo commented on May 14, 2024

I have managed to have it worked. Here is what my configuration.

  1. servlet-context.xml
    <beans:bean id="documentationController" class="com.mangofactory.swagger.springmvc.controller.DocumentationController"
    p:apiVersion="1.0"
    p:swaggerVersion="1.0"
    p:basePath="http://localhost:8080/mysite" />
  2. After restart your app server, if no Swagger-UI installed, from the web browser:
    http://localhost:8080/mysite/api-docs. You should get JSON back.
  3. Download and install Swagger-UI. In the search box, use http://localhost:8080/mysite/api-docs and Explore.

Hope it helps.

from springfox.

JohnnySlagle avatar JohnnySlagle commented on May 14, 2024

Thank you for the help. Sadly I still don't get any JSON back. This is my bean in the servlet-context.xml:

<bean id="documentationController" class="com.mangofactory.swagger.springmvc.controller.DocumentationController"
    p:apiVersion="1.0"
    p:swaggerVersion="1.0"
    p:basePath="http://localhost:8080/mysite" />

Yet still nothing.

from springfox.

WeipingGuo avatar WeipingGuo commented on May 14, 2024

During the server startup, did you see the following msg from the log:
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/api-docs/**],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.mangofactory.swagger.ControllerDocumentation com.mangofactory.swagger.springmvc.controller.DocumentationController.getApiDocumentation(javax.servlet.http.HttpServletRequest)

My case is little bit different because I modified the source code, but you should see the similar output.

You said you did not get JSON back, did you get 404?

If you turn on debug on log4j.xml, you should see more info during startup

from springfox.

JohnnySlagle avatar JohnnySlagle commented on May 14, 2024

Thank you for your response. I appreciate your help a lot. I cannot find anywhere in my logs that maps to /apidocs , /api-docs or the like.

You are correct, when I go where they should be, I get a 404 and the server tells me there is "No mapping found for HTTP request with URI [/mtcservices/apidocs] in DispatcherServlet with name 'mvc-dispatcher'"

I will try the log4j and see if there is any additional data but I should be having JBoss logging pretty much everything already.

Thank you for the help, I may just have to try to get it working with a static .json file (not the best option) but if it works.

from springfox.

vtn avatar vtn commented on May 14, 2024

The new version doesn't create an /apidoc endpoint but instead something like:

/resource/{apiName}

so try /mtcservices/resources/YOUR_API_NAME.

This can be seen in the logs:

INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/resources],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.wordnik.swagger.core.Documentation com.mangofactory.swagger.springmvc.controller.DocumentationController.getResourceListing()

INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/resources/{apiName}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.mangofactory.swagger.ControllerDocumentation com.mangofactory.swagger.springmvc.controller.DocumentationController.getApiDocumentation(java.lang.String)

from springfox.

WeipingGuo avatar WeipingGuo commented on May 14, 2024

Which new version? Maybe I missed something. I believe the base directory is still /api-docs:

@RequestMapping('/' + DocumentationController.CONTROLLER_ENDPOINT)
public class DocumentationController implements InitializingBean {

from springfox.

dilipkrish avatar dilipkrish commented on May 14, 2024

The documentation root should still be /api-docs (not ../resources)

from springfox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.