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

[C++][Pistache] Do not use JSON for primitive types in request body #3509

Merged

Conversation

muttleyxd
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
    @ravinikam @stkrwork @etherealjoy @MartinDelille

Description of the PR

Request body can contain any input, simple strings, CSV text or something else.

I have specified my request body like this:

    requestBody:
      content:
        text/csv:
          schema:
            type: string

Is it possible to check for content type of request body in Mustache template?

Current behavior is to parse request's body as if it's json. This causes any request to fall into 400 bad request exception branch, which means user provided handlers aren't executed at all.

Request body can contain any input, simple strings, CSV text or something else
@etherealjoy
Copy link
Contributor

@muttleyxd
Thanks for the PR.
There was no change in the samples code when you ran the shell script, right?

@muttleyxd
Copy link
Contributor Author

@etherealjoy
It looks like it, I made myself sure twice and it doesn't change samples.

$ git symbolic-ref --short HEAD
pistache-body-not-always-json
$ mvn clean install
(...) #long log here
$ ./bin/cpp-pistache-server-petstore.sh
(...) #again a lot of text
$ git status
On branch pistache-body-not-always-json
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   samples/server/petstore/cpp-pistache/.openapi-generator/VERSION

$ git diff
diff --git a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION
index 479c313e87..83a328a922 100644
--- a/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION
+++ b/samples/server/petstore/cpp-pistache/.openapi-generator/VERSION
@@ -1 +1 @@
-4.0.3-SNAPSHOT
\ No newline at end of file
+4.1.0-SNAPSHOT
\ No newline at end of file  

VERSION has changed, but I don't know whether that's an useful change to commit.

Maybe samples should be extended to include some body parameters with various types (though I don't have a plan for it now)

@etherealjoy
Copy link
Contributor

etherealjoy commented Jul 31, 2019

Ok, then no need to cmmit.

Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)

There was a CI error due to un commited files :(

@etherealjoy etherealjoy added this to the 4.1.0 milestone Aug 1, 2019
@etherealjoy
Copy link
Contributor

CI Issues not related to PR

@etherealjoy etherealjoy merged commit 4d28593 into OpenAPITools:master Aug 1, 2019
@wing328
Copy link
Member

wing328 commented Aug 10, 2019

@muttleyxd thanks for the PR, which has been included in the 4.1.0 release: https://twitter.com/oas_generator/status/1160000504455319553

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