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} />
|
||||
)}
|
||||
{(renderDiscriminatorSwitch && renderDiscriminatorSwitch(this.props)) || null}
|
||||
{field.const && (<FieldDetail label={'Value:'} value={field.const}/>) || null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ export interface LabelsConfig {
|
|||
recursive: string;
|
||||
arrayOf: string;
|
||||
webhook: string;
|
||||
const: string;
|
||||
}
|
||||
|
||||
export type LabelsConfigRaw = Partial<LabelsConfig>;
|
||||
|
@ -24,6 +25,7 @@ const labels: LabelsConfig = {
|
|||
recursive: 'Recursive',
|
||||
arrayOf: 'Array of ',
|
||||
webhook: 'Event',
|
||||
const: 'Value',
|
||||
};
|
||||
|
||||
export function setRedocLabels(_labels?: LabelsConfigRaw) {
|
||||
|
|
|
@ -55,6 +55,7 @@ export class FieldModel {
|
|||
extensions?: Record<string, any>;
|
||||
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
|
||||
|
|
|
@ -60,6 +60,7 @@ export class SchemaModel {
|
|||
rawSchema: OpenAPISchema;
|
||||
schema: MergedOpenAPISchema;
|
||||
extensions?: Record<string, any>;
|
||||
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');
|
||||
|
|
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> };
|
||||
content?: { [media: string]: OpenAPIMediaType };
|
||||
encoding?: Record<string, OpenAPIEncoding>;
|
||||
const?: any;
|
||||
}
|
||||
|
||||
export interface OpenAPIExample {
|
||||
|
@ -145,6 +146,7 @@ export interface OpenAPISchema {
|
|||
minProperties?: number;
|
||||
enum?: any[];
|
||||
example?: any;
|
||||
const?: string;
|
||||
}
|
||||
|
||||
export interface OpenAPIDiscriminator {
|
||||
|
|
Loading…
Reference in New Issue
Block a user