Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec generation doesn't honour the ",string" JSON struct tag #1510

Closed
neilgarb opened this issue May 3, 2018 · 1 comment
Closed

Spec generation doesn't honour the ",string" JSON struct tag #1510

neilgarb opened this issue May 3, 2018 · 1 comment
Labels
generate spec Related to spec generation from code

Comments

@neilgarb
Copy link
Contributor

neilgarb commented May 3, 2018

Problem statement

I have a field in a response struct which specifies that it's encoded as a string when marshalled to JSON.

// swagger:model
type Foo struct {
    Bar int64 `json:"bar,string"`
}

When I generate the spec for Foo, the type of Bar is integer, when it should in fact be string.

Proposed solution

In parseJSONTag(), also return a boolean indicating that the field has the ",string" directive. When the field's type is determined, override it with type:string and format: if the directive is present.

Swagger specification

2.0

Steps to reproduce

N/A

Environment

swagger version: 2.0
go version: 1.10.1
OS: macOS 10.12.6

@fredbi fredbi added the generate spec Related to spec generation from code label May 3, 2018
@casualjim
Copy link
Member

fixed by #1511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate spec Related to spec generation from code
Projects
None yet
Development

No branches or pull requests

3 participants