mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
feat: add const keyword
This commit is contained in:
parent
24c02e3c52
commit
aef48a18c8
|
@ -110,6 +110,7 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
||||||
<ExternalDocumentation externalDocs={schema.externalDocs} compact={true} />
|
<ExternalDocumentation externalDocs={schema.externalDocs} compact={true} />
|
||||||
)}
|
)}
|
||||||
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
|
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
|
||||||
|
{field.const && (<FieldDetail label={'Value:'} value={field.const}/>) || null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ export interface LabelsConfig {
|
||||||
recursive: string;
|
recursive: string;
|
||||||
arrayOf: string;
|
arrayOf: string;
|
||||||
webhook: string;
|
webhook: string;
|
||||||
|
const: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LabelsConfigRaw = Partial<LabelsConfig>;
|
export type LabelsConfigRaw = Partial<LabelsConfig>;
|
||||||
|
@ -24,6 +25,7 @@ const labels: LabelsConfig = {
|
||||||
recursive: 'Recursive',
|
recursive: 'Recursive',
|
||||||
arrayOf: 'Array of ',
|
arrayOf: 'Array of ',
|
||||||
webhook: 'Event',
|
webhook: 'Event',
|
||||||
|
const: 'Value',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function setRedocLabels(_labels?: LabelsConfigRaw) {
|
export function setRedocLabels(_labels?: LabelsConfigRaw) {
|
||||||
|
|
|
@ -55,6 +55,7 @@ export class FieldModel {
|
||||||
extensions?: Record<string, any>;
|
extensions?: Record<string, any>;
|
||||||
explode: boolean;
|
explode: boolean;
|
||||||
style?: OpenAPIParameterStyle;
|
style?: OpenAPIParameterStyle;
|
||||||
|
const?: any;
|
||||||
|
|
||||||
serializationMime?: string;
|
serializationMime?: string;
|
||||||
|
|
||||||
|
@ -111,6 +112,8 @@ export class FieldModel {
|
||||||
if (options.showExtensions) {
|
if (options.showExtensions) {
|
||||||
this.extensions = extractExtensions(info, options.showExtensions);
|
this.extensions = extractExtensions(info, options.showExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.const = this.schema?.const || info?.const || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
|
@ -60,6 +60,7 @@ export class SchemaModel {
|
||||||
rawSchema: OpenAPISchema;
|
rawSchema: OpenAPISchema;
|
||||||
schema: MergedOpenAPISchema;
|
schema: MergedOpenAPISchema;
|
||||||
extensions?: Record<string, any>;
|
extensions?: Record<string, any>;
|
||||||
|
const: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isChild if schema discriminator Child
|
* @param isChild if schema discriminator Child
|
||||||
|
@ -119,6 +120,7 @@ export class SchemaModel {
|
||||||
this.default = schema.default;
|
this.default = schema.default;
|
||||||
this.readOnly = !!schema.readOnly;
|
this.readOnly = !!schema.readOnly;
|
||||||
this.writeOnly = !!schema.writeOnly;
|
this.writeOnly = !!schema.writeOnly;
|
||||||
|
this.const = schema.const || '';
|
||||||
|
|
||||||
if (!!schema.nullable) {
|
if (!!schema.nullable) {
|
||||||
if (Array.isArray(this.type)) this.type.push('null');
|
if (Array.isArray(this.type)) this.type.push('null');
|
||||||
|
|
2
src/types/open-api.d.ts
vendored
2
src/types/open-api.d.ts
vendored
|
@ -99,6 +99,7 @@ export interface OpenAPIParameter {
|
||||||
examples?: { [media: string]: Referenced<OpenAPIExample> };
|
examples?: { [media: string]: Referenced<OpenAPIExample> };
|
||||||
content?: { [media: string]: OpenAPIMediaType };
|
content?: { [media: string]: OpenAPIMediaType };
|
||||||
encoding?: Record<string, OpenAPIEncoding>;
|
encoding?: Record<string, OpenAPIEncoding>;
|
||||||
|
const?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenAPIExample {
|
export interface OpenAPIExample {
|
||||||
|
@ -145,6 +146,7 @@ export interface OpenAPISchema {
|
||||||
minProperties?: number;
|
minProperties?: number;
|
||||||
enum?: any[];
|
enum?: any[];
|
||||||
example?: any;
|
example?: any;
|
||||||
|
const?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenAPIDiscriminator {
|
export interface OpenAPIDiscriminator {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user