rest-guide icon indicating copy to clipboard operation
rest-guide copied to clipboard

Response type for "/doc/openapi.yaml"

Open pvdbosch opened this issue 1 year ago • 2 comments

When documenting the "GET /doc/openapi.yaml" operation in OpenAPI, as in [doc-refdata], max compatibility with tooling is achieved when specifying the payload as binary:

    OpenApiResponse:
      description: OpenAPI document describing this API
      content:
        application/yaml:
          schema:
            type: string
            format: binary

Non-binary payload type: object has undefined behavior for YAML content-type. Binary format is also the only one allowed currently by the validator.

Can we document this payload format in the guide and add it to openapi-common? I often see problems with it in OpenAPIs (wrong media type or other schema).

Also, we could modify the [doc-refdata] rule to prefer publishing as YAML (SHOULD) over JSON (OPTIONAL), conform to [oas-yaml].

pvdbosch avatar Feb 27 '24 14:02 pvdbosch

Is "/doc/openapi.yaml" supposed to be defined in the OpenAPI definition? See https://github.com/belgif/rest-guide/issues/127

How do you handle serving referenced files like /doc/belgif/common/v1/common-v1.yaml? Or do you provide a fat yaml?

jpraet avatar Feb 27 '24 16:02 jpraet

Good question. We're currently doing this, as fat yaml, because otherwise the API Gateway blocks the request.

For documentation purpose, its self-referential so leads to chicken-or-egg problem. Maybe useful when client developers have another, possibly different, version of the OpenAPI document and want to check the current version on the server. However, in case of secured APIs, they're probably missing an access token to retrieve it...

pvdbosch avatar Feb 27 '24 16:02 pvdbosch