modrinth / docs

Our documentation site's source code.

Home Page:https://docs.modrinth.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenAPI spec: 'facets' parameter type is incorrect

nickrobson opened this issue · comments

Hey there! I'm working on a project which will be calling the Modrinth API for data, and I'm generating types, clients, etc. for calling the API using a spec-to-code generator.

I noticed that the OpenAPI spec for the facets parameter in /v2/search claims that the parameter can be present multiple times in the query, which is wrong. It appears to actually be describing what the string should deserialise to (an array of an array of strings) instead of what the parameter is on the query level (a string).

From the OpenAPI spec :

Query parameters can be primitive values, arrays and objects. OpenAPI 3.0 provides several ways to serialize objects and arrays in the query string.

Arrays can be serialized as:

  • form – /products?color=blue,green,red or /products?color=blue&color=green, depending on the explode keyword
  • spaceDelimited (same as collectionFormat: ssv in OpenAPI 2.0) – /products?color=blue%20green%20red
  • pipeDelimited (same as collectionFormat: pipes in OpenAPI 2.0) – /products?color=blue|green|red

In this case, I believe the type of the parameter should just be string, since the API expects a string to be sent (which is a JSON-serialised array of array of string).


The parameter is defined in the spec here:
https://github.com/modrinth/docs/blob/master/static/openapi.yaml#L1080-L1089


Working: Passing a string which is a JSON-serialised array of arrays of strings:

https://api.modrinth.com/v2/search?facets=%5B%5B%22project_type%3Amod%22%5D%2C%5B%22versions%3A1.19%22%2C%22versions%3A1.19.1%22%5D%5D&index=downloads&limit=10

Not working: Passing facets multiple times – the expected behaviour for a parameter that's an array of strings (or an array of arrays of strings).

https://api.modrinth.com/v2/search?facets=project_type%3Amod&facets=versions%3A1.19&facets=versions%3A1.19.1&index=downloads&limit=10

Query deserialize error: duplicate field `facets`