diff --git a/src/components/SecurityRequirement/OAuthFlow.tsx b/src/components/SecurityRequirement/OAuthFlow.tsx index 4b20e1f7..6197a30e 100644 --- a/src/components/SecurityRequirement/OAuthFlow.tsx +++ b/src/components/SecurityRequirement/OAuthFlow.tsx @@ -13,7 +13,7 @@ export interface OAuthFlowProps { export function OAuthFlowComponent(props: OAuthFlowProps) { const { type, flow, RequiredScopes } = props; const scopesNames = Object.keys(flow?.scopes || {}); - console.log('rended'); + return ( <> diff --git a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap index 3480ad6f..53cb5829 100644 --- a/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap @@ -207,6 +207,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -465,6 +474,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -698,6 +716,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -998,6 +1025,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -1256,6 +1292,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -1489,6 +1534,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -1745,6 +1799,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -2042,6 +2105,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -2300,6 +2372,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, @@ -2533,6 +2614,15 @@ exports[`Components SchemaView discriminator should correctly render SchemaView }, "rightPanel": Object { "backgroundColor": "#263238", + "servers": Object { + "overlay": Object { + "backgroundColor": "#fafafa", + "textColor": "#263238", + }, + "url": Object { + "backgroundColor": "#fff", + }, + }, "textColor": "#ffffff", "width": "40%", }, diff --git a/src/services/__tests__/fixtures/3.1/prefixItems.json b/src/services/__tests__/fixtures/3.1/prefixItems.json index 63a4d078..cd527297 100644 --- a/src/services/__tests__/fixtures/3.1/prefixItems.json +++ b/src/services/__tests__/fixtures/3.1/prefixItems.json @@ -133,6 +133,13 @@ ] } }, + "Case6": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/components/schemas/Tag" + } + }, "Cat": { "type": "object", "properties": { @@ -148,6 +155,29 @@ "type": "string" } } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "description": "Tag ID", + "allOf": [ + { + "$ref": "#/components/schemas/Id" + } + ] + }, + "name": { + "description": "tag name", + "type": "string", + "minLength": 1 + } + } + }, + "Id": { + "type": "integer", + "format": "int64", + "readOnly": true } } } diff --git a/src/services/__tests__/fixtures/arrayItems.json b/src/services/__tests__/fixtures/arrayItems.json index ebe25f34..51da75ea 100644 --- a/src/services/__tests__/fixtures/arrayItems.json +++ b/src/services/__tests__/fixtures/arrayItems.json @@ -133,6 +133,13 @@ ] } }, + "Case6": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/components/schemas/Tag" + } + }, "Cat": { "type": "object", "properties": { @@ -148,6 +155,29 @@ "type": "string" } } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "description": "Tag ID", + "allOf": [ + { + "$ref": "#/components/schemas/Id" + } + ] + }, + "name": { + "description": "tag name", + "type": "string", + "minLength": 1 + } + } + }, + "Id": { + "type": "integer", + "format": "int64", + "readOnly": true } } } diff --git a/src/services/__tests__/models/Schema.test.ts b/src/services/__tests__/models/Schema.test.ts index 3dfbf6f8..89c44365 100644 --- a/src/services/__tests__/models/Schema.test.ts +++ b/src/services/__tests__/models/Schema.test.ts @@ -212,6 +212,22 @@ describe('Models', () => { ]); }, ); + + test.each(eachArray)( + 'schemaDefinition should resolve prefixItems with additional array items', + specFixture => { + const spec = require(specFixture); + const parser = new OpenAPIParser(spec, undefined, opts); + const schema = new SchemaModel(parser, spec.components.schemas.Case6, '', opts); + expect(schema.type).toBe('array'); + expect(schema.typePrefix).toBe('Array of '); + expect(schema.items?.fields).toHaveLength(2); + expect(schema.items?.pointer).toEqual('#/components/schemas/Tag'); + expect(schema.isPrimitive).toBe(false); + expect(schema.items?.isPrimitive).toBe(false); + expect(schema.minItems).toBe(1); + }, + ); }); }); }); diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index 4816a149..afc45762 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -209,7 +209,8 @@ export class SchemaModel { this.displayFormat = this.items?.format || ''; this.typePrefix = this.items?.typePrefix || '' + l('arrayOf'); this.title = this.title || this.items?.title || ''; - this.isPrimitive = this.items?.isPrimitive || this.isPrimitive; + this.isPrimitive = + this.items?.isPrimitive !== undefined ? this.items?.isPrimitive : this.isPrimitive; if (this.example === undefined && this.items?.example !== undefined) { this.example = [this.items.example];