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

Auto parameter string default value without double quotation make api docs generating failed #272

Open
wutz opened this issue Mar 21, 2019 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@wutz
Copy link
Contributor

wutz commented Mar 21, 2019

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

nirvana api starting failed with logging:

FATAL 0321-12:50:40.034+08 api.go:61 | json: error calling MarshalJSON for type spec.Swagger: json: error calling MarshalJSON for type *spec.Paths: json: error calling MarshalJSON for type spec.PathItem: json: error calling MarshalJSON for type *spec.Operation: json: error calling MarshalJSON for type spec.OperationProps: json: error calling MarshalJSON for type spec.Parameter: json: error calling MarshalJSON for type *swagger.rawJSON: invalid character 'w' looking for beginning of value

What you expected to happen:

nirvana api can work correctly.

How to reproduce it (as minimally and precisely as possible):

Define a struct which relating to Auto parameter, set string default value without double quotation:

type Option struct {
  Hello string `source:"Query,hello,default=world"`
}

Anything else we need to know?:

If set default value with double quotation, then nirvana api can work, but bussiness function will be getting addition double quotation from that option.

type Option struct {
  Hello string `source:"Query,hello,default=\"world\""`
}

Additionally, how to support not basic type correctly, e.g.

type Option struct {
  Hello string `source:"Query,hello,default=\"world\""`
  Timeout time.Duration `source:"Query,timeout,default=10s"`
  Perm os.FileMode `source:"Query,perm,default=0755"`
}
@caicloud-bot caicloud-bot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 21, 2019
@kdada
Copy link
Collaborator

kdada commented Mar 21, 2019

For non-basic types, you can register custom converters by service.RegisterConverter().

@wutz
Copy link
Contributor Author

wutz commented Mar 21, 2019 via email

@wutz
Copy link
Contributor Author

wutz commented Mar 21, 2019 via email

@kdada
Copy link
Collaborator

kdada commented Mar 25, 2019

It's a problem. I have not found an effective way to make them work together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants