Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Is your feature request related to a problem? Please describe.
It should be possible to have endpoint with a full plain text request body like

  /dummy:
    post:
      requestBody:
        description: (to be documented)
        content:
          text/plain:
            schema:
              type: string
        required: true

Today it is completely ignored

Describe the solution you'd like
In openapi._add_body() we should have a additional line

        text_body, schemas = Endpoint.parse_request_text_body(
            body=data.requestBody, schemas=schemas, parent_name=endpoint.name, config=config
        )

And

    @staticmethod
    def parse_request_text_body(
        *, body: oai.RequestBody, schemas: Schemas, parent_name: str, config: Config
    ) -> Tuple[Union[Property, PropertyError, None], Schemas]:
        """Return text_body"""
        body_content = body.content
        text_body = body_content.get("text/plain")
        if text_body is not None and text_body.media_type_schema is not None:
            return property_from_data(
                name="text_body",
                required=True,
                data=text_body.media_type_schema,
                schemas=schemas,
                parent_name=parent_name,
                config=config,
            )
        return None, schemas

Describe alternatives you've considered

Additional context

You must be logged in to vote

Replies: 3 comments · 6 replies

Comment options

I can probably provide a PR

You must be logged in to vote
0 replies
Comment options

I am facing the same issue for response. text/plain does not seems to be supported

You must be logged in to vote
0 replies
Comment options

This finally works with 0.16.0

You must be logged in to vote
6 replies
@dbanty
Comment options

Clearly I did a bad job of searching for related discussions 🤦 . 0.16.0 added support for plain text responses, not requests.

@webbnh
Comment options

Thanks for the confirmation. (Sorry to bring the bad news....)

@webbnh
Comment options

It looks like replacing text/plain with application/octet-stream will work around the problem, at least for the moment.

@willr3
Comment options

We are also running into an issue generating a python client that consumes text/plain:

      requestBody:
        content:
          text/plain:
            schema:
              type: string
#> openapi-python-client --version
openapi-python-client version: 0.17.2

#> openapi-python-client generate --path ...
...
Unsupported content type text/plain

I am looking at changing the content type but are there plans to support the text/plain content type?

@marshalc
Comment options

Finding this whilst trying 0.22.0... turns out a large chunk of the API I'm trying to parse is either "Unsupported content type text/plain" or "Unsupported content type application/xml". If it helps, I've attached the file I'm working with - it comes from the NextGen Mirth Integration Engine

openapi.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement 🍭 OpenAPI Compliance Supporting a new bit of the OpenAPI spec
6 participants
Converted from issue

This discussion was converted from issue #542 on August 13, 2023 01:51.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.