Skip to content

Improve support for OpenAPI enum items that contain documentation #2481

Open
@BDQ

Description

Today, if I use the following Smithy enum definition:

@documentation("The status of the enrollment request.")
enum EnrollmentStatus {
  @documentation("The enrollment request is pending review.")
  PENDING = "PENDING",
  @documentation("The enrollment request has been approved.")
  APPROVED = "APPROVED",
  @documentation("The enrollment request has been rejected.")
  REJECTED = "REJECTED"
}

The following OpenAPI output will be produced, as can be seen below, the per item documentation lines are lost:

{
    "EnrollmentStatus": {
        "type": "string",
        "description": "The status of the enrollment. Only Stedi can set or update this property.",
        "enum": [
            "PENDING",
            "APPROVED",
            "REJECTED"
        ]
    }
}

Using OAS 3.1.x (and JSON Schema 2020-12) enums can be defined with oneOf along with const to allow documentation to included for each item, for example:

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"properties": {
		"status": {
			"type": "string",
			"description": "The status of the enrollment request.",
			"oneOf": [
				{
					"const": "PENDING",
					"description": "The enrollment request is pending."
				},
				{
					"const": "APPROVED",
					"description": "The enrollment request has been approved."
				},
				{
					"const": "REJECTED",
					"description": "The enrollment request has been rejected."
				}
			]
		}
	}
}

It would be great if we could have the same support in the openapi plugin.

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