fix(components): add support for oneOf/anyOf JSON Schema keywords in parameter-row rendering (#9934)

Refs #7912
This commit is contained in:
Oliwia Rogala
2024-05-14 11:54:44 +02:00
committed by GitHub
parent dcc87aaca6
commit 9037acf508
6 changed files with 170 additions and 2 deletions

View File

@@ -0,0 +1,49 @@
/**
* @prettier
*/
describe("Parameter with oneOf and anyOf keywords in OpenAPI 3.0.x", () => {
it("should render correct form fields", () => {
cy.visit("/?url=/documents/features/parameters-one-of-any-of-oas3.yaml")
.get("#operations-default-get_")
.click()
cy.get(".parameters-col_description")
.eq(1)
.find("select")
.should("exist")
.and("have.value", "ascending")
cy.get(".parameters-col_description")
.eq(2)
.find("input")
.should("exist")
.and("have.value", "test")
cy.get(".parameters-col_description")
.eq(3)
.find("textarea")
.should("exist")
.and("contain", "\"eq\": \"active\"")
})
})
describe("Parameter with oneOf and anyOf keywords in OpenAPI 3.1.0.", () => {
it("should render correct form fields", () => {
cy.visit("/?url=/documents/features/parameters-one-of-any-of-oas31.yaml")
.get("#operations-default-get_")
.click()
cy.get(".parameters-col_description")
.eq(1)
.find("select")
.should("exist")
.and("have.value", "ascending")
cy.get(".parameters-col_description")
.eq(2)
.find("input")
.should("exist")
.and("have.value", "test")
cy.get(".parameters-col_description")
.eq(3)
.find("textarea")
.should("exist")
.and("contain", "\"eq\": \"active\"")
})
})

View File

@@ -0,0 +1,50 @@
openapi: 3.0.0
paths:
/:
get:
parameters:
- name: enum
in: query
schema:
oneOf:
- type: string
default: ascending
enum:
- ascending
- descending
- name: string
in: query
default: test
schema:
anyOf:
- type: string
- name: object
in: query
schema:
oneOf:
- type: object
properties:
eq:
type: string
enum:
- active
- archived
neq:
type: string
enum:
- active
- archived
in:
type: array
items:
type: string
enum:
- active
- archived
notIn:
type: array
items:
type: string
enum:
- active
- archived

View File

@@ -0,0 +1,50 @@
openapi: 3.1.0
paths:
/:
get:
parameters:
- name: enum
in: query
schema:
oneOf:
- type: string
default: ascending
enum:
- ascending
- descending
- name: string
in: query
default: test
schema:
anyOf:
- type: string
- name: object
in: query
schema:
oneOf:
- type: object
properties:
eq:
type: string
enum:
- active
- archived
neq:
type: string
enum:
- active
- archived
in:
type: array
items:
type: string
enum:
- active
- archived
notIn:
type: array
items:
type: string
enum:
- active
- archived

View File

@@ -9,6 +9,7 @@ import ParameterRow from "core/components/parameter-row"
import {
memoizedSampleFromSchema,
memoizedCreateXMLExample,
mergeJsonSchema,
} from "core/plugins/json-schema-5-samples/fn/index"
import makeGetSampleSchema from "core/plugins/json-schema-5-samples/fn/get-sample-schema"
import makeGetJsonSampleSchema from "core/plugins/json-schema-5-samples/fn/get-json-sample-schema"
@@ -103,6 +104,7 @@ describe("bug #4557: default parameter values", function () {
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
getSampleSchema: makeGetSampleSchema(getSystem),
mergeJsonSchema,
},
})
const props = {

View File

@@ -9,6 +9,7 @@ import ParameterRow from "core/components/parameter-row"
import {
memoizedSampleFromSchema,
memoizedCreateXMLExample,
mergeJsonSchema,
} from "core/plugins/json-schema-5-samples/fn/index"
import makeGetSampleSchema from "core/plugins/json-schema-5-samples/fn/get-sample-schema"
import makeGetJsonSampleSchema from "core/plugins/json-schema-5-samples/fn/get-json-sample-schema"
@@ -31,6 +32,7 @@ describe("<ParameterRow/>", () => {
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
getSampleSchema: makeGetSampleSchema(getSystem),
mergeJsonSchema,
},
oas3Selectors: { activeExamplesMember: () => {} },
getConfigs: () => ({}),
@@ -276,6 +278,7 @@ describe("bug #5573: zero default and example values", function () {
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
getSampleSchema: makeGetSampleSchema(getSystem),
mergeJsonSchema,
},
})
const props = {
@@ -329,6 +332,7 @@ describe("bug #5573: zero default and example values", function () {
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
getSampleSchema: makeGetSampleSchema(getSystem),
mergeJsonSchema,
},
})
const props = {