{
render() {
const itemsSchema = this.props.schema.items!;
+ const schema = this.props.schema;
+
const itemConstraintSchema = (
min: number | undefined = undefined,
max: number | undefined = undefined,
) => ({ type: 'array', minItems: min, maxItems: max });
- const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems));
+ const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema?.schema?.minItems, itemsSchema?.schema?.maxItems));
+
+ if (schema.displayType && !itemsSchema && !minMaxItems.length) {
+ return (
+ {schema.displayType}
+
);
+ }
return (
diff --git a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap
index f293088f..fe5617ed 100644
--- a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap
+++ b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap
@@ -20,6 +20,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"activeOneOf": 0,
"const": "",
"constraints": Array [],
+ "contentEncoding": undefined,
+ "contentMediaType": undefined,
"default": undefined,
"deprecated": false,
"description": "",
@@ -71,6 +73,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"activeOneOf": 0,
"const": "",
"constraints": Array [],
+ "contentEncoding": undefined,
+ "contentMediaType": undefined,
"default": undefined,
"deprecated": false,
"description": "",
diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts
index adb2de19..e5b36ae1 100644
--- a/src/services/models/Schema.ts
+++ b/src/services/models/Schema.ts
@@ -61,6 +61,8 @@ export class SchemaModel {
schema: MergedOpenAPISchema;
extensions?: Record;
const: any;
+ contentEncoding?: string;
+ contentMediaType?: string;
/**
* @param isChild if schema discriminator Child
@@ -120,10 +122,14 @@ export class SchemaModel {
this.readOnly = !!schema.readOnly;
this.writeOnly = !!schema.writeOnly;
this.const = schema.const || '';
+ this.contentEncoding = schema.contentEncoding;
+ this.contentMediaType = schema.contentMediaType;
- if (!!schema.nullable) {
- if (Array.isArray(this.type) && !this.type.includes('null')) {
+ if (!!schema.nullable || schema['x-nullable']) {
+ if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {
this.type = [...this.type, 'null'];
+ } else if (!Array.isArray(this.type) && (this.type !== null || this.type !== 'null')) {
+ this.type = [this.type, 'null'];
}
}
diff --git a/src/types/open-api.ts b/src/types/open-api.ts
index d55e44b1..03898457 100644
--- a/src/types/open-api.ts
+++ b/src/types/open-api.ts
@@ -147,6 +147,8 @@ export interface OpenAPISchema {
enum?: any[];
example?: any;
const?: string;
+ contentEncoding?: string;
+ contentMediaType?: string;
}
export interface OpenAPIDiscriminator {
diff --git a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap
index 1aa507f9..7807e39e 100644
--- a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap
+++ b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap
@@ -2187,6 +2187,12 @@ Object {
"id": Object {
"$ref": "#/components/schemas/Id",
},
+ "image": Object {
+ "contentEncoding": "base64",
+ "contentMediaType": "image/png",
+ "description": "User image",
+ "type": "string",
+ },
"lastName": Object {
"description": "User last name",
"example": "Smith",
diff --git a/src/utils/openapi.ts b/src/utils/openapi.ts
index c31e3cd2..ad267722 100644
--- a/src/utils/openapi.ts
+++ b/src/utils/openapi.ts
@@ -83,6 +83,8 @@ const schemaKeywordTypes = {
maxLength: 'string',
minLength: 'string',
pattern: 'string',
+ contentEncoding: 'string',
+ contentMediaType: 'string',
items: 'array',
maxItems: 'array',