Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enum descriptions in schema object #981

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions demo/examples/tests/enumDescriptions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
openapi: 3.0.1
info:
title: Enum descriptions test
description: Demonstrates of enum descriptions.
version: 1.0.0
tags:
- name: enumDescriptions
description: enumDescriptions tests
paths:
/filter-one-status:
get:
tags:
- enumDescriptions
summary: Get entities by status
description: Get all entities or search by status
parameters:
- name: status
in: query
required: true
schema:
type: string
enum:
- active
- inactive
- pending
x-enumDescriptions:
active: The entity is active
inactive: The entity is inactive
pending: The entity is pending approval
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/EnumDescriptionsEntity"
/filter-multiple-status:
get:
tags:
- enumDescriptions
summary: Get entities by multiple status
description: Get all entities or search by multiple status
parameters:
- name: status
in: query
required: true
schema:
type: array
items:
type: string
enum:
- active
- inactive
- pending
x-enumDescriptions:
active: The entity is active
inactive: The entity is inactive
pending: The entity is pending approval
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/EnumDescriptionsEntity"
components:
schemas:
EnumDescriptionsEntity:
type: object
properties:
id:
type: string
name:
type: string
status:
type: string
enum:
- active
- inactive
- pending
x-enumDescriptions:
active: The entity is active
inactive: The entity is inactive
pending: The entity is pending approval
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export function createParamsDetails({ parameters, type }: Props) {
param: {
...param,
enumDescriptions: Object.entries(
param?.schema?.items?.["x-enumDescriptions"] ?? {}
param?.schema?.["x-enumDescriptions"] ??
param?.schema?.items?.["x-enumDescriptions"] ??
{}
),
},
});
Expand Down
Loading