diff --git a/demo/openapi-3-1.yaml b/demo/openapi-3-1.yaml index 9c875fc6..e960d523 100644 --- a/demo/openapi-3-1.yaml +++ b/demo/openapi-3-1.yaml @@ -1181,6 +1181,7 @@ components: type: object properties: id: + type: number description: Tag ID $ref: '#/components/schemas/Id' name: diff --git a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap index 53cb5829..c1748f0f 100644 --- a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap @@ -823,6 +823,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView "discriminator": Object { "propertyName": "type", }, + "format": undefined, "parentRefs": Array [ "#/components/schemas/Pet", ], @@ -1643,6 +1644,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView "discriminator": Object { "propertyName": "type", }, + "format": undefined, "parentRefs": Array [ "#/components/schemas/Pet", ], @@ -2721,6 +2723,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView "discriminator": Object { "propertyName": "type", }, + "format": undefined, "parentRefs": Array [ "#/components/schemas/Pet", ], diff --git a/src/services/OpenAPIParser.ts b/src/services/OpenAPIParser.ts index 15cd5239..21da1ef2 100644 --- a/src/services/OpenAPIParser.ts +++ b/src/services/OpenAPIParser.ts @@ -1,6 +1,6 @@ import { OpenAPIRef, OpenAPISchema, OpenAPISpec, Referenced } from '../types'; -import { isArray, isBoolean, IS_BROWSER } from '../utils/'; +import { isArray, isBoolean, IS_BROWSER } from '../utils'; import { JsonPointer } from '../utils/JsonPointer'; import { getDefinitionName, isNamedDefinition } from '../utils/openapi'; import { RedocNormalizedOptions } from './RedocNormalizedOptions'; @@ -173,7 +173,7 @@ export class OpenAPIParser { keys.some(k => k !== 'description' && k !== 'title' && k !== 'externalDocs') ) { return { - allOf: [rest, resolved], + allOf: [resolved, rest], }; } else { // small optimization @@ -244,6 +244,7 @@ export class OpenAPIParser { for (const { $ref: subSchemaRef, schema: subSchema } of allOfSchemas) { const { type, + format, enum: enumProperty, properties, items, @@ -263,6 +264,7 @@ export class OpenAPIParser { receiver.type = [...type, ...receiver.type]; } else { receiver.type = type; + receiver.format = format; } } diff --git a/src/services/__tests__/models/__snapshots__/Schema.test.ts.snap b/src/services/__tests__/models/__snapshots__/Schema.test.ts.snap index b0f6c73e..102231d6 100644 --- a/src/services/__tests__/models/__snapshots__/Schema.test.ts.snap +++ b/src/services/__tests__/models/__snapshots__/Schema.test.ts.snap @@ -4,6 +4,7 @@ exports[`Models Schema schemaDefinition should resolve field with conditional op Object { "allOf": undefined, "default": undefined, + "format": undefined, "items": Object { "allOf": undefined, "format": "url", @@ -24,6 +25,7 @@ exports[`Models Schema schemaDefinition should resolve field with conditional op Object { "allOf": undefined, "default": undefined, + "format": undefined, "items": Object { "allOf": undefined, "format": "url", @@ -48,6 +50,7 @@ Object { exports[`Models Schema schemaDefinition should resolve schema with conditional operators 1`] = ` Object { "allOf": undefined, + "format": undefined, "maxItems": 2, "parentRefs": Array [], "properties": Object { @@ -57,6 +60,7 @@ Object { "enum": Array [ 10, ], + "format": undefined, "items": Object { "allOf": undefined, "format": "url", @@ -83,6 +87,7 @@ Object { exports[`Models Schema schemaDefinition should resolve schema with conditional operators 2`] = ` Object { "allOf": undefined, + "format": undefined, "maxItems": 20, "parentRefs": Array [], "properties": Object { diff --git a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap index 17fda88e..5f526a74 100644 --- a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap +++ b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap @@ -2261,6 +2261,7 @@ Object { "id": Object { "$ref": "#/components/schemas/Id", "description": "Tag ID", + "type": "number", }, "name": Object { "description": "Tag name",