Skip to content

[rust-server] Allow text/html plaintext responses#1180

Closed
colelawrence wants to merge 1 commit intoOpenAPITools:masterfrom
colelawrence:events_service-rust_server-adjustments
Closed

[rust-server] Allow text/html plaintext responses#1180
colelawrence wants to merge 1 commit intoOpenAPITools:masterfrom
colelawrence:events_service-rust_server-adjustments

Conversation

@colelawrence
Copy link
Copy Markdown

@colelawrence colelawrence commented Oct 5, 2018

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 and ./bin/security/{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\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Hello @frol, @farcaller, and @bjgill,

This addition to the rust-server generator enables the use of text/html responses as plaintext.

@bjgill, I'm sorry I did not add an issue to gather feedback.

I can run shell scripts in the checklist in a few moments

@colelawrence colelawrence changed the title Allow text/html plaintext responses [rust-server] Allow text/html plaintext responses Oct 5, 2018
consumesXml = true;
} else if (isMimetypePlainText(mimeType)) {
consumesPlainText = true;
} else if (isMimetypeHtmlText(mimeType)) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Consuming html plaintext may not make sense (I don't know what is supposed to happen), we can adjust this.

@bjgill
Copy link
Copy Markdown
Contributor

bjgill commented Oct 6, 2018

Thanks for the contribution. This seems like a sensible way of handling HTML initially. We can then integrate a full parser/generator later if needed.

It would, however, be nice to see the effect this PR has - would it be possible to add a sample HTML endpoint to https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/rust-server/rust-server-test.yaml? That should give us some confidence that the change has the right effect, as well as making it harder to regress this function in future.

@colelawrence
Copy link
Copy Markdown
Author

colelawrence commented Oct 6, 2018

@bjgill yes, I will add a test for this!

@bjgill
Copy link
Copy Markdown
Contributor

bjgill commented Oct 8, 2018

Thanks. I suspect you'll want to add something like:

  /html:
    post:
      summary: Test HTML handling
      consumes: [text/html]
      produces: [text/html]
      parameters:
      - in: body
        name: body
        required: true
        schema:
          type: string
      responses:
        200:
          description: Success
          schema:
            type: string

@wing328 wing328 modified the milestones: 3.3.1, 3.3.2 Oct 15, 2018
@bjgill
Copy link
Copy Markdown
Contributor

bjgill commented Oct 24, 2018

I've now got this working (with sample) at https://github.com/Metaswitch/openapi-generator/tree/rust-server-html. Unless you want to fold those changes into this PR, I'll open a new PR tomorrow.

@bjgill
Copy link
Copy Markdown
Contributor

bjgill commented Oct 26, 2018

Thanks for your contribution. I've created #1329, which adds the sample update.

@bjgill bjgill closed this Oct 26, 2018
@colelawrence
Copy link
Copy Markdown
Author

colelawrence commented Oct 26, 2018 via email

bjgill added a commit that referenced this pull request Nov 5, 2018
Builds on #1180 by @colelawrence. This addition to the rust-server generator enables the use of text/html responses as plaintext.

I've added an html endpoint to the sample to demonstrate that this works (and fixed the problem that that uncovered).
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
Builds on OpenAPITools#1180 by @colelawrence. This addition to the rust-server generator enables the use of text/html responses as plaintext.

I've added an html endpoint to the sample to demonstrate that this works (and fixed the problem that that uncovered).
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