Allow showing SchemaDefinition as child

This commit is contained in:
Magnus Jensen 2024-04-28 13:15:51 +02:00
parent 31d88a184b
commit 88e7d72d56
2 changed files with 6 additions and 9 deletions

View File

@ -15,6 +15,7 @@ export interface ObjectDescriptionProps {
showReadOnly?: boolean;
showWriteOnly?: boolean;
showExample?: boolean;
showAsChild?: boolean;
parser: OpenAPIParser;
options: RedocNormalizedOptions;
}
@ -39,15 +40,10 @@ export class SchemaDefinition extends React.PureComponent<ObjectDescriptionProps
private _mediaModel: MediaTypeModel;
private get mediaModel() {
const { parser, schemaRef, exampleRef, options } = this.props;
const { parser, schemaRef, exampleRef, options, showAsChild } = this.props;
if (!this._mediaModel) {
this._mediaModel = new MediaTypeModel(
parser,
'json',
false,
SchemaDefinition.getMediaType(schemaRef, exampleRef),
options,
);
const info = SchemaDefinition.getMediaType(schemaRef, exampleRef);
this._mediaModel = new MediaTypeModel(parser, 'json', false, info, options, showAsChild);
}
return this._mediaModel;

View File

@ -25,10 +25,11 @@ export class MediaTypeModel {
isRequestType: boolean,
info: OpenAPIMediaType,
options: RedocNormalizedOptions,
showAsChild?: boolean,
) {
this.name = name;
this.isRequestType = isRequestType;
this.schema = info.schema && new SchemaModel(parser, info.schema, '', options);
this.schema = info.schema && new SchemaModel(parser, info.schema, '', options, showAsChild);
this.onlyRequiredInSamples = options.onlyRequiredInSamples;
this.generatedPayloadSamplesMaxDepth = options.generatedPayloadSamplesMaxDepth;
if (info.examples !== undefined) {