GithubHelp home page GithubHelp logo

Comments (3)

jwalton avatar jwalton commented on July 22, 2024 1

I think if you set explode to false it will do what you're expecting. Should it do what you're expecting here anyways? That's something the OpenAPI spec is very hazy on - there's lots of details about how to serialize parameters in RFC 6570, but not so many on how to deserialize them.

In this case, explode defaults to true, so a client should serialize this request as:

GET /api/v0/items?fields=field1&fields=field2

So technically your client is at fault. :P If the client sent:

GET /api/v0/items?fields=field1,field2&fields=field3

(Ignoring for the fact that in this case it's an enum) I would definitely want to deserialize this as ['field1,field2', 'filed3'] - it seems likely the comma is supposed to be there (even thought really the client should have serialized it as a %2C, but then why is the client sending this as half exploded?). But then, in this case:

GET /api/v0/items?fields=field1,field2

It's more ambiguous. If explode were false, it would CLEARLY be an array of values, but with explode true...

That's the logic behind the decisions I made. I'm not entirely opposed to changing it, though. :)

from exegesis.

pvince avatar pvince commented on July 22, 2024

Setting explode to false worked. I was basing my functionality off the swagger-connect project using a Swagger 2.0 based specification. It looks like maybe in OpenAPI 3.0 they either clarified or changed the default behavior?

Reading the spec a bit more carefully, it looks like the current implemented functionality matches the spec around serialization of parameters. Specifically looking at the Style Examples

The default style for query parameters is form. Further, when style is set to form, explode defaults to true.

Looking at that table, when style: form and explode: true the expected array serialization is color=blue&color=black&color=brown.

On a side note, I am experimenting with both upgrading our specification from Swagger 2.0 to OpenAPI 3.0 along with switching from swagger-node to exegesis-express. This projects extensive & accurate documentation is an incredible breath of fresh air after working with swagger-node for almost 2 years. Thanks for pointing me towards the explode setting.

from exegesis.

jwalton avatar jwalton commented on July 22, 2024

No problem. And glad to hear you're having a good time with Exegesis and the docs. This project started when I was writing a series of blog posts about how to get around some of the weird and undocumented parts in swagger-node, and then I started reading about OpenAPI 3.x and realized it would solve a few problems I had, so I decided to just roll my own library. I tried to focus pretty heavily on writing good documentation, exactly because node-swagger is... not as well documented as I'd like. Glad to hear it's paying off. :)

If you find anything confusing in the docs, please raise an issue!

from exegesis.

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.