Coder Social home page Coder Social logo

Comments (7)

glennjones avatar glennjones commented on May 18, 2024 1

Support for Swagger v2.x was added in December 2015 and we now have partial fixes for some of the path template issues

The plug-in now supported for paths like:

/books/{id}/cover
/library/shelves/{shelfId}/book/{id?}

There is no support for paths like

/books/{id*}
/books/{id*3}

You still need to declare the path params in the routes validate object

validate: {
            params: {
                shelfId: Joi.string().required()
                id: Joi.string().optional()
            },
}

Sorry it took so long

from hapi-swagger.

glennjones avatar glennjones commented on May 18, 2024

Hi sorry its taken a while to get back to you.

Had a look at the Swagger spec and it looks like it only works with optional parameters for form and querystrings, but not path parameters. This is one of area where HAPI has wider functionality than Swagger.

It would be possible to fix this, you would need to modify the swagger.js file function SwaggerOperation.prototype.urlify. I am trying not to make this type of change as it will make the plug-in harder to maintain. The swagger.js file is updated quite often. You could of course fork the project and do it yourself. If enough people want this, I will consider making the changes needed.

from hapi-swagger.

Gregy avatar Gregy commented on May 18, 2024

Hi,
I just ran into the same issue.

+1

from hapi-swagger.

metaodi avatar metaodi commented on May 18, 2024

+1, would like to see this "fixed"

from hapi-swagger.

marcsmith avatar marcsmith commented on May 18, 2024

+1 as well

from hapi-swagger.

glennjones avatar glennjones commented on May 18, 2024

Hi Everyone

Taken another look at this

This use case of a optional path is not supported by swagger 1.2 spec and the current swagger UI code. swagger-api/swagger-ui#380

At the bottom of the comments on the issue Tony Tam says that the issue maybe fix with swagger 2.0 spec and new swagger UI.

I am just about to start the work to move over to 2.0 swagger, so I hope there will be a fix for you somewhere down the line. I am not sure how long it going to take to rebuild the plug-in, but I will post on this issue again when I have something.

from hapi-swagger.

jeffm13 avatar jeffm13 commented on May 18, 2024

Glenn,

I'll try to check it out in the next few days. I just wanted to say thank you now for all the work you've done on this plugin. It keeps on getting better and you apparently have endless energy. Great work!

Jeff

from hapi-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.