Skip to content

Add support for content-type for yaml files #392

Description

@dtkav

Is your feature request related to a problem? Please describe.
yaml is a common media type in APIs for serving/accepting openapi specs, manifests, k8s configs, etc.

For example: https://github.com/APIs-guru/openapi-directory/blob/8af5478deebb70c01dc8155825528c18353d9deb/APIs/stoplight.io/api-v1/openapi.yaml#L171-L177

Describe the solution you'd like
It would be great to support one or more of the (unfortunately many) media types for yaml.
I found examples of the following in https://github.com/APIs-guru/openapi-directory/ :
application/x-yaml
application/yaml
text/x-yaml
text/yaml

IMO it probably makes sense to only support the "json subset" of YAML with a strict safe-loader, but I suppose it might make sense for it to be configurable.

Describe alternatives you've considered
It could make sense to support a plugin interface for content-types - it will be impossible to support them all :/
It also seems reasonable for openapi-python-client to specialize in json and pass other types as files.

Activity

  1. changed the title [-]Add support for content-type for yaml[/-] [+]Add support for content-type for yaml files[/+] on Apr 24, 2021
  2. dbanty commented on Apr 25, 2021

    @dbanty
    Collaborator

    Is the goal specifically just to return the text of the yaml or to parse the yaml into some OpenAPI-defined type? Having all unregistered content types just get spit into a bytes or similar feels like a pretty easy win, then you can do whatever you want with it. Adding the ability to parse YAML and stick it into a response object will require us to add a dependency.

    I have never encountered YAML as a web response that was intended to be used programmatically in a way other than text (e.g. download this openapi.yaml and put it into a file, or pipe it into a generator). But I feel like the content type might as well just be text if it wasn't intended to be parsed.

  3. locked and limited conversation to collaborators on Aug 13, 2023
  4. converted this issue into a discussion #828 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions