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

fix(api-docs): handle the default value of parameter correctly #333

Merged
merged 2 commits into from
Jun 2, 2020

Conversation

iawia002
Copy link

@iawia002 iawia002 commented Jun 1, 2020

What this PR does / why we need it:

For now, if we set a default value for a field of an auto parameter, the API docs generation will fail with the error below:

FATAL 0601-16:59:25.166+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 's' after top-level value

Which issue(s) this PR is related to (optional, link to 3rd issue(s)):

Fixes #

Reference to #272

Special notes for your reviewer:

/cc @hezhizhen @supereagle

Release note:

NONE

@caicloud-bot caicloud-bot added release-note-none Denotes a PR that doesn't merit a release note. caicloud-cla: yes Indicates the PR's author has not signed the Caicloud CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 1, 2020
@iawia002
Copy link
Author

iawia002 commented Jun 1, 2020

/cherrypick release-0.2

@caicloud-bot
Copy link
Contributor

@iawia002: once the present PR merges, I will cherry-pick it on top of release-0.2 in a new PR and assign it to you.

In response to this:

/cherrypick release-0.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

utils/generators/swagger/generator.go Outdated Show resolved Hide resolved
utils/generators/swagger/generator.go Outdated Show resolved Hide resolved
utils/generators/swagger/generator.go Outdated Show resolved Hide resolved
@iawia002
Copy link
Author

iawia002 commented Jun 2, 2020

All comments addressed, PTAL @hezhizhen

@hezhizhen
Copy link
Contributor

/lgtm
but I'm not sure if it's expected...

@caicloud-bot caicloud-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2020
@iawia002
Copy link
Author

iawia002 commented Jun 2, 2020

but I'm not sure if it's expected...

What? Setting an empty default value for those non-basic types?

@iawia002
Copy link
Author

iawia002 commented Jun 2, 2020

If default values of non-basic types are not handled, the effect is as follows, the Swagger UI will not display the default values, that's all, I think it's better than returning errors directly during document generation.

Screen Shot 2020-06-02 at 12 06 44

So any more comments?

@hezhizhen
Copy link
Contributor

If default values of non-basic types are not handled, the effect is as follows, the Swagger UI will not display the default values, that's all, I think it's better than returning errors directly during document generation.

Screen Shot 2020-06-02 at 12 06 44

So any more comments?

works for me.

@iawia002
Copy link
Author

iawia002 commented Jun 2, 2020

/approve

@caicloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hezhizhen, iawia002

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@caicloud-bot caicloud-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 2, 2020
@caicloud-bot caicloud-bot merged commit bf6c5fc into caicloud:master Jun 2, 2020
@iawia002 iawia002 deleted the fix-default-value branch June 2, 2020 08:26
@caicloud-bot
Copy link
Contributor

@iawia002: new pull request created: #334

In response to this:

/cherrypick release-0.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. caicloud-cla: yes Indicates the PR's author has not signed the Caicloud CLA. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants