Skip to content

Commit

Permalink
Merge pull request #981 from tuanpt-0634/support-schema-enum-descript…
Browse files Browse the repository at this point in the history
…ions

Support enum descriptions in schema object
  • Loading branch information
sserrata authored Oct 2, 2024
2 parents 296475b + 3eed555 commit 0063174
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
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

0 comments on commit 0063174

Please sign in to comment.