Git Product home page Git Product logo

Comments (14)

carlsonngo avatar carlsonngo commented on June 19, 2024 1

Feeding the data to swagger-ui will display the paths in the wrong order. This might be confusing for people if they want to preserve the order in the generated api docs.

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

@carlsonngo thanks for reporting, I am curious how important this order is to you?

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

@carlsonngo thanks for the context.

from play-swagger.

slouc avatar slouc commented on June 19, 2024

+1 For me it's not even reverse order, but a completely random one. Using 0.2.0.

from play-swagger.

bilongc avatar bilongc commented on June 19, 2024

+1 for me, it is displayed as random order. Using play 2.5.4, play-swagger 0.5.0

from play-swagger.

tculshaw avatar tculshaw commented on June 19, 2024

So how do we order, using play 2.5.x, play-swagger 0.5.3? Looks random to me.

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

@tculshaw we haven't implement the feature the preserve the ordering in the routes file. Any PR will be more than welcome :)

from play-swagger.

tculshaw avatar tculshaw commented on June 19, 2024

If any one is interested I have a partial solution, hence this isn't a formal pull request.

Replacing the path function in SwaggerSpecGenerator, I order the main unique paths as per the ROUTE file, but NOT the order where multiple methods (GET,PUT,POST,DELETE) apply to the same path. It's a lot better than it used to be, and will suffice for my needs, but still not quite 100%!

private def paths(routes: Seq[Route], prefix: String, tag: Option[Tag]): JsObject = {
    JsObject {
      val endPointEntries = routes.flatMap(route => endPointEntry(route, prefix, tag))
      val zgbp = endPointEntries.zipWithIndex.groupBy(_._1._1)
      import collection.mutable.LinkedHashMap
      val lhm = LinkedHashMap(zgbp.toSeq sortBy (_._2.head._2): _*)
      val gbp2 = lhm mapValues (_ map (_._1)) toSeq
      gbp2.toSeq.map( x => (x._1,x._2.map(_._2).reduce(_ deepMerge _)))
    }
 }

I banged my head against the wall to get this going, so hope this is helpful to somebody!

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

Thanks very much @tculshaw, it's not quite 100% but it's still a step forward. I will appreciate it if you want to submit a PR (just need a simple test for the ordering).

from play-swagger.

tculshaw avatar tculshaw commented on June 19, 2024

This can now be closed? Thanks for accepting my change #152

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

@tculshaw it's still a partial solution right? ("NOT the order where multiple methods (GET,PUT,POST,DELETE) apply to the same path")

from play-swagger.

tculshaw avatar tculshaw commented on June 19, 2024

from play-swagger.

kailuowang avatar kailuowang commented on June 19, 2024

I imagine it would be nice for some users, but I don't particularly have that need in my projects. Thanks for offering! And thanks again for your contribution!

from play-swagger.

tculshaw avatar tculshaw commented on June 19, 2024

from play-swagger.

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.