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/Dart2] Resolve an exception with status 204 and no body. #7647

Merged
merged 8 commits into from
Oct 13, 2020
Merged

[Fix/Dart2] Resolve an exception with status 204 and no body. #7647

merged 8 commits into from
Oct 13, 2020

Conversation

noordawod
Copy link
Contributor

@noordawod noordawod commented Oct 11, 2020

This resolves a problem in API client when a remote server returns no body with a status code of 204 (default behavior according to the spec.)

@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12) @wing328 @sbu-WBT @agilob

  • 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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@noordawod noordawod changed the title Resolve an exception situation when a remote server returns 204 with no body. [Fix/Dart2] Resolve an exception with status 204 and no body. Oct 11, 2020
@agilob
Copy link
Contributor

agilob commented Oct 11, 2020

You havent committed something, this code doesnt compile

@noordawod
Copy link
Contributor Author

I have, and now again -- fixed the compile error, by the way.

@@ -56,6 +56,6 @@ String parameterToString(dynamic value) {
String _decodeBodyBytes(Response response) {
final contentType = response.headers['content-type'];
return contentType != null && contentType.contains('application/json')
? utf8.decode(response.bodyBytes)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is getting complex fast

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I checked and it's not what you see above. Now that line shows:

  ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)

@agilob
Copy link
Contributor

agilob commented Oct 11, 2020

Can you add a simple test for the 204 code status please?

@noordawod
Copy link
Contributor Author

Can you add a simple test for the 204 code status please?

Sure thing. Any pointers where to look? :)

@agilob
Copy link
Contributor

agilob commented Oct 11, 2020

openapi-generator/samples/client/petstore/dart2/petstore/test/pet_test.dart

@noordawod
Copy link
Contributor Author

noordawod commented Oct 12, 2020

openapi-generator/samples/client/petstore/dart2/petstore/test/pet_test.dart

Thanks.

I tried finding the openapi yaml file for the server, but I cannot find it anywhere. If I'm to add a test for 204, I would like to see if the server has an endpoint returning a 204.

So, where can I find the openapi spec. file for the server?

@noordawod
Copy link
Contributor Author

openapi-generator/samples/client/petstore/dart2/petstore/test/pet_test.dart

Would it be possible for you to augment the pr and add this test? I didn't find the openapi file so I don't know which endpoint returns a 204.

@wing328
Copy link
Member

wing328 commented Oct 13, 2020

@noordawod currently, we don't have a test for 204 in the petstore spec.

Is it correct to say that you've tested the change locally with your own API(s) and verify the issue has been addressed in this PR?

@noordawod
Copy link
Contributor Author

@noordawod currently, we don't have a test for 204 in the petstore spec.

Is it correct to say that you've tested the change locally with your own API(s) and verify the issue has been addressed in this PR?

100% correct. I discovered the issue because I had a 204 in the first place, and this fix addresses it correctly.

@agilob
Copy link
Contributor

agilob commented Oct 13, 2020

So let's get this in and replace 2_0 spec with more complex 3_0

@wing328 wing328 added this to the 5.0.0 milestone Oct 13, 2020
@wing328 wing328 merged commit 3c869d5 into OpenAPITools:master Oct 13, 2020
@noordawod noordawod deleted the bugfix/dart2-status-204 branch October 13, 2020 16:47
jimschubert added a commit that referenced this pull request Oct 17, 2020
* master: (66 commits)
  [Typescript][Angular] Fix generated README when using apiModulePrefix (#7725)
  remove outdated scala files (#7723)
  [FEAT][TYPESCRIPT-ANGULAR] Add configurationPrefix option to allow generating unique configuration token (#7731)
  [bug] Fix FILES sort and path provider issue (#7729)
  better csharp tests (#7727)
  [go] Improve examples generation (#7576)
  Fixes #7635: typescript-inversify generator wrongly handles array type parameters (#7636)
  [Java] Fix import mapping for arrays with reference items of type string (#7182)
  [Java][Native] Support oneOf/anyOf schemas (#7263)
  [BUG][Ada] Incorrect client Ada code generated (#7719)
  add cake, sbt integration (#7713)
  Use 3.0 spec in documentations, update docs  (#7710)
  remove github.com/antihax/optional from go.sum (#7692)
  Update junit to newer version (4.13.1) (#7690)
  [Fix/Dart2] Resolve an exception with status 204 and no body. (#7647)
  [typescript-angular] pass array as a single JSON string to url query when queryParamObjectFormat=json (fix #7620) (#7649)
  Add back HttpSigningConfiguration.cs
  remove HTTPSigningConfiguration.cs
  add AnyType support to Swift generators (#7644)
  fix warning, remove trailing spaces (#7659)
  ...
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