Skip to content

Add support for plain text request body #542

Closed

Description

@kairntech

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

Activity

  1. added
    ✨ enhancement
    on Dec 3, 2021
  2. kairntech commented on Dec 3, 2021

    @kairntech
    Author

    I can probably provide a PR

  3. rubenfiszel commented on Dec 4, 2021

    @rubenfiszel

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

  4. added
    🍭 OpenAPI Compliance
    on Aug 13, 2023
  5. locked and limited conversation to collaborators on Aug 13, 2023
  6. converted this issue into a discussion #821 on Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨ enhancement🍭 OpenAPI Compliance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions