I’m working on the support for array parameters in Oaskit and there is a difference between how OpenAPI and Phoenix handle them.
In OpenAPI you can declare a query parameter with explode: true which means that passing ?users=Alice&users=Bob should give users: ["Alice", "Bob"] when deserialized.
With Phoenix, this will give users: "Bob". You need to encode it as ?users[]=Alice&users[]=Bob if you want an array.
OpenAPI can support that, you just have to include the [] suffix in the parameter name: "parameters": [{"name": "users[]", "in": "query", "schema": {"type": "array"}}].
So my goal is to automatically include the brackets suffix for array parameters when dumping the API spec to JSON. But I need to check if this is correctly handled by different clients.
My team uses Orval and it seems to work fine. The query parameter can be called users or users[] in the OpenAPI spec, in both cases Orval sends the same thing. Though it sends users%5B%5D instead of users[] but this is valid.
I would like to do the same test with different clients, starting by those used in the community. Can you tell my what client or generator do you use for OpenAPI 3.1?
You lost me here. Who and how and why is dumping an API spec to JSON? From what format? Do you mean from f.ex. a JS or Elixir project that have tags that the tooling uses to produce a spec?
I only ever used the official openapi-generator but I strongly recommend openapi-tui for inspection. Helped me multiple times in the last year.
Yes sorry, many tools provide the ability to declare operations and parameters in the controllers. So when you want to generate a client you have to gather all of his into a json or yaml spec!
Thank you I’ll check those out!
hmmm well openapi-tui does not seem very helpful honnestly.
:query
unknown command, available commands are send, query, […]
I have honestly forgotten, last time I used it was several months ago, but I was generating Rust clients for various APIs and then making sure they work and make small adjustments here and there. In general I was very happy with the quality. But not much recent memories on using it for Elixir, sorry.
Did you find it confusing to use?
RE: openapi-tui, it was also some months ago. Not sure I ever used :query though, I was kind of exploring what was there in APIs and then used the generated clients.