Comments (3)
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.
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.
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)
- Can not demand an array to be one or more items long HOT 2
- Crash with recursive definition in referenced OpenAPI file HOT 5
- Incorrectly failing validation under a weird condition HOT 4
- Validation error of request body when oneOf is used HOT 5
- Crash with recursive definition in referenced OpenAPI file is back again
- Does not work well with newest json-ptr (1.3.1) HOT 2
- Your .dependabot/config.yml contained invalid details HOT 1
- Export class from controller HOT 2
- Could not find controller if controller is a .ts file HOT 2
- Can we access "ExegesisContext" at express middleware(app.use) not controllers/*.ts HOT 1
- How to filter the request body by only passing the defined requestBody schema? HOT 2
- Security vulnerability in `json-ptr` HOT 4
- Exegesis 3.0.0 using updated ajv outputs issues with OpenAPI spec, but 2.0.0 did not HOT 5
- res.redirect not supported HOT 3
- Is OpenAPI 3.1 supported?
- Bump json-ptr to fix security vulnerability HOT 1
- Support for additional string formats HOT 2
- json-schema-ref-parser dependency breaks node engine < 17 HOT 3
- How to use exegesis with multipart/form-data?
- Mime-types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exegesis.