feat: add const keyword

This commit is contained in:
Alex Varchuk 2021-05-26 11:50:47 +03:00
parent 24c02e3c52
commit aef48a18c8
5 changed files with 10 additions and 0 deletions

View File

@ -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>
);
}

View File

@ -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) {

View File

@ -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

View File

@ -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');

View File

@ -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 {