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

[go] Support for response status code ranges #10075

Merged
merged 1 commit into from
Aug 25, 2021
Merged

[go] Support for response status code ranges #10075

merged 1 commit into from
Aug 25, 2021

Conversation

NathanBaulch
Copy link
Contributor

This PR adds support for response ranges in Go clients, as defined in section 4.8.16.2 of the spec.
This includes a simple response sorting change in DefaultCodegen.java (originally introduced by @thiagoarrais) that should make this feature easier to support in all languages.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
  • File the PR against the correct branch: master, 5.3.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@NathanBaulch
Copy link
Contributor Author

Copy link
Contributor

@jirikuncar jirikuncar left a comment

Choose a reason for hiding this comment

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

👍

if localVarHTTPResponse.StatusCode >= 500
{{/is5xx}}
{{/range}}
{{^range}}
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR. Shall we remove the following before and after the {{#range}} ... {{/range}} check?

		{{^is1xx}}
		{{^is2xx}}

...
		{{/is2xx}}
		{{/is1xx}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing those checks causes unreachable code to be generated due to the if localVarHTTPResponse.StatusCode >= 300 { a few lines up. We're only interested in decoding "unsuccessful" responses at this point and those negative checks are the only way to do this AFAIK.

Copy link
Member

Choose a reason for hiding this comment

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

👌

@wing328
Copy link
Member

wing328 commented Aug 22, 2021

cc @OpenAPITools/generator-core-team as the change covers the default codegen class

@wing328 wing328 merged commit 9c66d33 into OpenAPITools:master Aug 25, 2021
@wing328 wing328 added this to the 5.3.0 milestone Aug 25, 2021
@NathanBaulch NathanBaulch deleted the go-response-ranges branch August 25, 2021 03:47
@NathanBaulch
Copy link
Contributor Author

I believe this PR also addresses #6829 and #7473.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants