fix: merge reference for openapi 3.1 (#2063)

This commit is contained in:
Alex Varchuk 2022-07-05 13:19:30 +03:00 committed by GitHub
parent e26c8b23d9
commit 87541e45dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 2 deletions

View File

@ -1181,6 +1181,7 @@ components:
type: object
properties:
id:
type: number
description: Tag ID
$ref: '#/components/schemas/Id'
name:

View File

@ -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",
],

View File

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

View File

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

View File

@ -2261,6 +2261,7 @@ Object {
"id": Object {
"$ref": "#/components/schemas/Id",
"description": "Tag ID",
"type": "number",
},
"name": Object {
"description": "Tag name",