diff --git a/docs/api.html b/docs/api.html
index e6092d63..666500ee 100644
--- a/docs/api.html
+++ b/docs/api.html
@@ -1045,6 +1045,12 @@
Supported vendor extensions
Usage Example |
+
+ x-extensible-enum |
+ Use this vendor-extension to provide document extensible enums/growable lists.
+ |
+ Usage Example |
+
x-badges |
Use this vendor-extension to annotate end-points with short color coded lables.
diff --git a/docs/examples/extensible-enum.html b/docs/examples/extensible-enum.html
new file mode 100644
index 00000000..1080ec43
--- /dev/null
+++ b/docs/examples/extensible-enum.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/list.html b/docs/list.html
index cb5e98d9..78200067 100644
--- a/docs/list.html
+++ b/docs/list.html
@@ -325,6 +325,13 @@ RapiDoc Mini
+
+ Extensible Enums
+
+ Support for x-extensible-enum (vendor extension) in schemas
+
+
+
Endpoint Badges
diff --git a/docs/specs/x-extensible-enum.yaml b/docs/specs/x-extensible-enum.yaml
new file mode 100644
index 00000000..aec6b963
--- /dev/null
+++ b/docs/specs/x-extensible-enum.yaml
@@ -0,0 +1,61 @@
+openapi: 3.0.0
+info:
+ title: x-extensible-enum Example
+ description: Example API demonstrating x-extensible-enum usage.
+ version: 1.0.0
+tags:
+ - name: Person
+ description: Operations related to people
+servers:
+ - url: https://api.example.com
+paths:
+ /people:
+ post:
+ summary: Create person
+ description: Create a new person with various attributes including hobbies and marital status.
+ operationId: createPerson
+ tags:
+ - Person
+ requestBody:
+ description: Person object that needs to be added
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name:
+ type: string
+ hobbies:
+ type: array
+ minItems: 1
+ maxItems: 3
+ items:
+ type: string
+ x-extensible-enum:
+ - computers
+ - hiking
+ - swimming
+ - movies
+ - music
+ - dancing
+ - reading
+ - painting
+ default: hiking
+ tags:
+ type: array
+ items:
+ type: string
+ maritalStatus:
+ type: string
+ enum:
+ - married
+ - unmarried
+ - widowed
+ required:
+ - name
+ - hobbies
+ responses:
+ "200":
+ description: successful operation
+ "404":
+ description: not found
diff --git a/src/styles/schema-styles.js b/src/styles/schema-styles.js
index b84abf3b..dec657a4 100644
--- a/src/styles/schema-styles.js
+++ b/src/styles/schema-styles.js
@@ -89,6 +89,7 @@ export default css`
.null { color:var(--red); }
.bool, .boolean { color:var(--orange) }
.enum { color:var(--purple) }
+.xext { color:var(--purple) }
.cons { color:var(--purple) }
.recu { color:var(--brown) }
.toolbar {
diff --git a/src/utils/schema-utils.js b/src/utils/schema-utils.js
index a0c89b20..8bfb71b4 100644
--- a/src/utils/schema-utils.js
+++ b/src/utils/schema-utils.js
@@ -36,14 +36,18 @@ export function getTypeInfo(schema) {
let constrain = '';
// let examples;
+ const enumValues = schema.enum || schema['x-extensible-enum'];
if (schema.$ref) {
const n = schema.$ref.lastIndexOf('/');
const schemaNode = schema.$ref.substring(n + 1);
dataType = `{recursive: ${schemaNode}} `;
} else if (schema.type) {
dataType = Array.isArray(schema.type) ? schema.type.join('┃') : schema.type;
- if (schema.format || schema.enum || schema.const) {
- dataType = dataType.replace('string', schema.enum ? 'enum' : schema.const ? 'const' : schema.format);
+ if (schema.format || schema.enum || schema.const || schema['x-extensible-enum']) {
+ dataType = dataType.replace(
+ 'string',
+ schema.enum ? 'enum' : schema.const ? 'const' : schema['x-extensible-enum'] ? 'x-extensible-enum' : schema.format,
+ );
}
if (schema.nullable) {
dataType += '┃null';
@@ -79,20 +83,21 @@ export function getTypeInfo(schema) {
// Set Allowed Values
info.allowedValues = schema.const
? schema.const
- : Array.isArray(schema.enum)
- ? schema.enum.map((v) => (getPrintableVal(v))).join('┃')
+ : Array.isArray(enumValues)
+ ? enumValues.map((v) => (getPrintableVal(v))).join('┃')
: '';
if (dataType === 'array' && schema.items) {
const arrayItemType = schema.items?.type;
const arrayItemDefault = getPrintableVal(schema.items.default);
+ const arrayEnumValues = schema.items?.enum || schema.items?.['x-extensible-enum'];
info.arrayType = `${schema.type} of ${Array.isArray(arrayItemType) ? arrayItemType.join('') : arrayItemType}`;
info.default = arrayItemDefault;
info.allowedValues = schema.items.const
? schema.const
- : Array.isArray(schema.items?.enum)
- ? schema.items.enum.map((v) => (getPrintableVal(v))).join('┃')
+ : Array.isArray(arrayEnumValues)
+ ? arrayEnumValues.map((v) => (getPrintableVal(v))).join('┃')
: '';
}
if (dataType.match(/integer|number/g)) {
|