nytimes / openapi2proto

A tool for generating Protobuf v3 schemas and gRPC service definitions from OpenAPI specifications
Apache License 2.0
964 stars 98 forks source link

Cannot unmarshal bool into Go struct field XXX of type openapi2proto.XXXX #60

Closed rhzs closed 6 years ago

rhzs commented 6 years ago

Golang version: go version go1.10 darwin/amd64.

Step by step to reproduce:

  1. go get -u github.com/NYTimes/openapi2proto/cmd/openapi2proto
  2. Trying to convert Swagger file from https://github.com/apigee/openbank/blob/master/openapi/accountv1-0.json
  3. openapi2proto -spec accountv1-0.json -options
  4. Failed to convert.
    2018/03/02 00:23:30 unable to load spec: unable to parse referenced file: json: cannot unmarshal bool into Go struct field Items.additionalProperties of type openapi2proto.Items

Expectation: Should not see error and able to convert swagger file.

jprobinson commented 6 years ago

I don't see it listed as a boolean in the official Open API spec here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

But I do see it is referenced in the swagger documentation: https://swagger.io/specification/

Not sure the use case of having it as a boolean as it seems like just omitting the property is a cleaner solution, but regardless, it seems like an odd but valid option.

If changing additionalProperties to an interface{} is simple, I should have a fix in pretty quickly.