go-openapi / strfmt

openapi toolkit common string formats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ObjectId.String() breaks swagger validation and CLI

dimovnike opened this issue · comments

Function ObjectId.String() at

strfmt/bson.go

Line 98 in ac88b91

return bsonprim.ObjectID(id).String()
must use bsonprim.ObjectID(id).Hex() instead of string. The current version breaks swagger validation and CLI generation.

For swagger validation problems please see this issue: go-swagger/go-swagger#2616 (comment)

As for CLI - it sends values in the form of ObjectID("value") to server.
(NOTE: CLI doesn't support ObjectId yet but I tried to implement it and hit this problem)

Changing the String() function as suggested by @youyuanwu the issue above will solve both cases.