Bungie-net / api

Resources for the Bungie.net API
Other
1.22k stars 92 forks source link

OpenAPI 3 spec contains invalid integer format `byte` #1452

Closed gdavison closed 3 years ago

gdavison commented 3 years ago

The OpenAPI 3 spec file, openapi.json contains number of parameters of type integer, with format byte. However, the OpenAPI 3 standard only defines the integer formats int32 and int64.

This causes tools such as https://github.com/deepmap/oapi-codegen to fail to parse the file to generate client code. e.g.

$ oapi-codegen -generate types ./openapi.json > types.gen.go
error generating code: error creating operation definitions: error describing global parameters for GET//CommunityContent/Get/{sort}/{mediaFilter}/{page}/: error generating type for param (sort): invalid integer format: byte
joshhunt commented 3 years ago

From the spec:

the format property is an open string-valued property, and can have any value. Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification

From my personal experience, using an off the shelf codegen tool with the Bungie OpenAPI spec even once you fix these issues doesn't give great results. Enums in particular I've found pretty rough.

Instead, there exists a number of bungie-api-specific codegen projects that are not too difficult to port to your language of choiuce.

This is what I would recommend - fork one of these projects and replace the templates with your own language. While it might seem a bit daunting, it shouldn't be too tricky.

gdavison commented 3 years ago

Thanks for the tips. I'd seen https://github.com/DestinyItemManager/bungie-api-ts already. Maybe I should have gone with C# instead of Go, or even used my project as an excuse to finally learn F# 😂