I am not finding any YAML files in https://github.com/inaturalist/iNaturalistAPI/tree/main/openapi ; instead there are Joi specifications. I found some tools online for converting Joi specs to openapi specs, but before I try running those, is there an existing solution to this?
The OpenAPI 3.0 spec for v2 is dynamically generated. It can be found at https://api.inaturalist.org/v2/api-docs . Now that I’m looking at it I see one validation error I’ll fix - the include_ancestors parameter is listed as a path parameter but it should be a query parameter. The v1 spec (OpenAPI 2.0/Swagger) is at https://api.inaturalist.org/v1/swagger.json if you’d rather use that. Both are JSON but easily converted to YAML if you need that specifically
Generating the Go client code using oapi-codegen fails with a spec validation error:
% go generate
error generating code: error creating operation definitions: path '/observations/species_counts' has 0 positional parameters, but spec has 1 declared
exit status 1
generate.go:3: running "go": exit status 1
Structural error at paths./observations/species_counts.get.parameters.97
should have required property 'required'
missingProperty: required
Jump to line 11449
Semantic error at paths./observations/species_counts.get.parameters.97.name
Path parameter "include_ancestors" must have the corresponding {include_ancestors} segment in the "/observations/species_counts" path
Jump to line 11454
I was able to use Gemini CLI to identify and fix the error in my copy of api.json:
On line 16117 in the pretty printed api.json from https://api.inaturalist.org/v2/api-docs, “in”: “path” should be “in”: “query” for the “include_ancestors” parameter for the “/observations/species_counts” path.
I’m not sure how to fix this in the upstream server, but this was enough to enable me to generate the Go client code, so resolving this thread.