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

Allow overriding swagger type in struct fields #234

Merged

Conversation

nkly
Copy link
Contributor

@nkly nkly commented Nov 2, 2018

This PR adds support for a new struct field tag, swaggertype. It allows user to redefine the resulting swagger type of a struct field. It comes in 2 formats:

  • swaggertype:<prim_type> sets the swagger type of the field to the given <prim_type>
  • swaggertype:array,<prim_type> sets the swagger type of the field to "array" and the swagger type of its items to <prim_type>

This feature is useful when you have custom types that are not supported by swag tool yet, but nevertheless have a corresponding swagger type that fits them well, i.e. sql.NullInt64 can be simply integer, big.Float can be number, etc. While it would be nice to support these types out of the box, it is not possible to do so for every custom wrapper; that's why I think this feature could be valuable, but please feel free to disagree :)

@pei0804
Copy link
Member

pei0804 commented Nov 5, 2018

Oh nice idea.
I thought it was good.

pei0804
pei0804 previously approved these changes Nov 5, 2018
This PR adds support for a new struct field tag, `swaggertype`. It
allows user to redefine the resulting swagger type of a struct field.
It comes in 2 formats:

- `swaggertype:<prim_type>` sets the swagger type of the field to the
given `<prim_type>`
- `swaggertype:array,<prim_type>` sets the swagger type of the field to
"array" and the swagger type of its items to `<prim_type>`
@nkly nkly force-pushed the allow-overriding-swagger-types-in-structs branch from 9363c21 to 7f2f5d9 Compare November 5, 2018 09:19
@nkly nkly closed this Nov 5, 2018
@nkly nkly reopened this Nov 5, 2018
Copy link
Member

@easonlin404 easonlin404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@easonlin404 easonlin404 merged commit c0507b2 into swaggo:master Nov 6, 2018
@nkly nkly deleted the allow-overriding-swagger-types-in-structs branch November 6, 2018 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants