diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx
index ac362a40..be102622 100644
--- a/src/components/Fields/FieldDetails.tsx
+++ b/src/components/Fields/FieldDetails.tsx
@@ -110,6 +110,7 @@ export class FieldDetails extends React.PureComponent
)}
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
+ {field.const && () || null}
);
}
diff --git a/src/services/Labels.ts b/src/services/Labels.ts
index f5fa1fd1..8e89bc2f 100644
--- a/src/services/Labels.ts
+++ b/src/services/Labels.ts
@@ -9,6 +9,7 @@ export interface LabelsConfig {
recursive: string;
arrayOf: string;
webhook: string;
+ const: string;
}
export type LabelsConfigRaw = Partial;
@@ -24,6 +25,7 @@ const labels: LabelsConfig = {
recursive: 'Recursive',
arrayOf: 'Array of ',
webhook: 'Event',
+ const: 'Value',
};
export function setRedocLabels(_labels?: LabelsConfigRaw) {
diff --git a/src/services/models/Field.ts b/src/services/models/Field.ts
index 1154c9a8..ef031ab8 100644
--- a/src/services/models/Field.ts
+++ b/src/services/models/Field.ts
@@ -55,6 +55,7 @@ export class FieldModel {
extensions?: Record;
explode: boolean;
style?: OpenAPIParameterStyle;
+ const?: any;
serializationMime?: string;
@@ -111,6 +112,8 @@ export class FieldModel {
if (options.showExtensions) {
this.extensions = extractExtensions(info, options.showExtensions);
}
+
+ this.const = this.schema?.const || info?.const || '';
}
@action
diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts
index fb0c5164..8749625e 100644
--- a/src/services/models/Schema.ts
+++ b/src/services/models/Schema.ts
@@ -60,6 +60,7 @@ export class SchemaModel {
rawSchema: OpenAPISchema;
schema: MergedOpenAPISchema;
extensions?: Record;
+ const: any;
/**
* @param isChild if schema discriminator Child
@@ -119,6 +120,7 @@ export class SchemaModel {
this.default = schema.default;
this.readOnly = !!schema.readOnly;
this.writeOnly = !!schema.writeOnly;
+ this.const = schema.const || '';
if (!!schema.nullable) {
if (Array.isArray(this.type)) this.type.push('null');
diff --git a/src/types/open-api.d.ts b/src/types/open-api.d.ts
index 90ed467b..d55e44b1 100644
--- a/src/types/open-api.d.ts
+++ b/src/types/open-api.d.ts
@@ -99,6 +99,7 @@ export interface OpenAPIParameter {
examples?: { [media: string]: Referenced };
content?: { [media: string]: OpenAPIMediaType };
encoding?: Record;
+ const?: any;
}
export interface OpenAPIExample {
@@ -145,6 +146,7 @@ export interface OpenAPISchema {
minProperties?: number;
enum?: any[];
example?: any;
+ const?: string;
}
export interface OpenAPIDiscriminator {