feat: apply cumulative update to address various issues (#10324)
This commit is contained in:
@@ -35,7 +35,7 @@ const OAI3_SYSTEM = {
|
||||
isOAS3: () => true,
|
||||
specJson: () => {
|
||||
return fromJS({
|
||||
openapi: "3.0.0",
|
||||
openapi: "3.0.4",
|
||||
components: {
|
||||
securitySchemes: {
|
||||
basicAuth: {
|
||||
|
||||
@@ -112,8 +112,6 @@ describe("auth plugin - selectors", () => {
|
||||
})
|
||||
|
||||
it("should fail gracefully with bad data", () => {
|
||||
const securityDefinitions = null
|
||||
|
||||
const system = {
|
||||
authSelectors: {
|
||||
definitionsToAuthorize() {
|
||||
|
||||
@@ -26,6 +26,7 @@ describe("getSampleSchema", () => {
|
||||
const getSampleSchema = makeGetSampleSchema(getSystem)
|
||||
|
||||
beforeEach(() => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
Date = function () {
|
||||
this.toISOString = function () {
|
||||
return "2018-07-07T07:07:05.189Z"
|
||||
@@ -34,6 +35,7 @@ describe("getSampleSchema", () => {
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
Date = oriDate
|
||||
})
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ describe("getSampleSchema", () => {
|
||||
const getSampleSchema = makeGetSampleSchema(getSystem)
|
||||
|
||||
beforeEach(() => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
Date = function () {
|
||||
this.toISOString = function () {
|
||||
return "2018-07-07T07:07:05.189Z"
|
||||
@@ -32,6 +33,7 @@ describe("getSampleSchema", () => {
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
Date = oriDate
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import Immutable, { List } from "immutable"
|
||||
import { Select, Input, TextArea } from "core/components/layout-utils"
|
||||
import { mount, render } from "enzyme"
|
||||
import * as JsonSchemaComponents from "core/plugins/json-schema-5/components/json-schema-components"
|
||||
import { foldType } from "core/plugins/json-schema-2020-12-samples/fn/index"
|
||||
|
||||
const components = {...JsonSchemaComponents, Select, Input, TextArea}
|
||||
|
||||
@@ -21,7 +22,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "string",
|
||||
enum: ["one", "two"]
|
||||
@@ -44,7 +49,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "string",
|
||||
enum: ["one", "two"]
|
||||
@@ -65,7 +74,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
schema: Immutable.fromJS({
|
||||
type: "string",
|
||||
@@ -89,7 +102,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "boolean"
|
||||
})
|
||||
@@ -112,7 +129,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "boolean",
|
||||
enum: ["true"]
|
||||
@@ -135,7 +156,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "boolean",
|
||||
required: true
|
||||
@@ -159,7 +184,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
schema: Immutable.fromJS({
|
||||
type: "boolean",
|
||||
@@ -186,7 +215,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
updateQueue.push({ value })
|
||||
},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
errors: List(),
|
||||
schema: Immutable.fromJS({
|
||||
type: "object",
|
||||
@@ -215,7 +248,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "yo",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "NotARealType"
|
||||
})
|
||||
@@ -237,7 +274,11 @@ describe("<JsonSchemaComponents.JsonSchemaForm/>", function(){
|
||||
value: "yo",
|
||||
onChange: () => {},
|
||||
keyName: "",
|
||||
fn: {},
|
||||
fn: {
|
||||
jsonSchema202012: {
|
||||
foldType,
|
||||
},
|
||||
},
|
||||
schema: Immutable.fromJS({
|
||||
type: "NotARealType",
|
||||
format: "NotARealFormat"
|
||||
|
||||
@@ -23,22 +23,6 @@ describe("<SchemesContainer/>", function(){
|
||||
},
|
||||
getComponent: c => components[c]
|
||||
}
|
||||
const twoSecurityDefinitions = {
|
||||
"petstore_auth": {
|
||||
"type": "oauth2",
|
||||
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
|
||||
"flow": "implicit",
|
||||
"scopes": {
|
||||
"write:pets": "modify pets in your account",
|
||||
"read:pets": "read your pets"
|
||||
}
|
||||
},
|
||||
"api_key": {
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
|
||||
it("renders Schemes inside SchemesContainer if schemes are provided", function(){
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { fromJS } from "immutable"
|
||||
import { isOAS30, isSwagger2 } from "core/plugins/oas3/helpers"
|
||||
|
||||
const isOAS3Shorthand = (version) => isOAS30(fromJS({
|
||||
const isOAS30Shorthand = (version) => isOAS30(fromJS({
|
||||
openapi: version
|
||||
}))
|
||||
|
||||
@@ -9,45 +9,46 @@ const isSwagger2Shorthand = (version) => isSwagger2(fromJS({
|
||||
swagger: version
|
||||
}))
|
||||
|
||||
describe("isOAS3", function () {
|
||||
describe("isOAS30", function () {
|
||||
it("should recognize valid OAS3 version values", function () {
|
||||
expect(isOAS3Shorthand("3.0.0")).toEqual(true)
|
||||
expect(isOAS3Shorthand("3.0.1")).toEqual(true)
|
||||
expect(isOAS3Shorthand("3.0.4")).toEqual(true)
|
||||
expect(isOAS3Shorthand("3.0.11111")).toEqual(true)
|
||||
expect(isOAS3Shorthand("3.0.0-rc0")).toEqual(false)
|
||||
|
||||
|
||||
expect(isOAS30Shorthand("3.0.0")).toEqual(true)
|
||||
expect(isOAS30Shorthand("3.0.1")).toEqual(true)
|
||||
expect(isOAS30Shorthand("3.0.2")).toEqual(true)
|
||||
expect(isOAS30Shorthand("3.0.3")).toEqual(true)
|
||||
expect(isOAS30Shorthand("3.0.4")).toEqual(true)
|
||||
expect(isOAS30Shorthand("3.0.25")).toEqual(true)
|
||||
})
|
||||
|
||||
it("should fail for invalid OAS3 version values", function () {
|
||||
expect(isOAS3Shorthand("3.0")).toEqual(false)
|
||||
expect(isOAS3Shorthand("3.0.")).toEqual(false)
|
||||
expect(isOAS3Shorthand("2.0")).toEqual(false)
|
||||
expect(isOAS30Shorthand("3.0")).toEqual(false)
|
||||
expect(isOAS30Shorthand("3.0.")).toEqual(false)
|
||||
expect(isOAS30Shorthand("3.0.01")).toEqual(false)
|
||||
expect(isOAS30Shorthand("2.0")).toEqual(false)
|
||||
expect(isOAS30Shorthand("3.0.0-rc0")).toEqual(false)
|
||||
})
|
||||
|
||||
it("should gracefully fail for non-string values", function () {
|
||||
expect(isOAS3Shorthand(3.0)).toEqual(false)
|
||||
expect(isOAS3Shorthand(3)).toEqual(false)
|
||||
expect(isOAS3Shorthand({})).toEqual(false)
|
||||
expect(isOAS3Shorthand(null)).toEqual(false)
|
||||
expect(isOAS30Shorthand(3.0)).toEqual(false)
|
||||
expect(isOAS30Shorthand(3)).toEqual(false)
|
||||
expect(isOAS30Shorthand({})).toEqual(false)
|
||||
expect(isOAS30Shorthand(null)).toEqual(false)
|
||||
})
|
||||
|
||||
it("should gracefully fail when `openapi` field is missing", function () {
|
||||
expect(isOAS30(fromJS({
|
||||
openApi: "3.0.0"
|
||||
openApi: "3.0.4"
|
||||
}))).toEqual(false)
|
||||
expect(isOAS3Shorthand(null)).toEqual(false)
|
||||
expect(isOAS30Shorthand(null)).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("isSwagger2", function () {
|
||||
it("should recognize valid Swagger 2.0 version values", function () {
|
||||
expect(isSwagger2Shorthand("2.0")).toEqual(true)
|
||||
expect(isSwagger2Shorthand("2.0-rc0")).toEqual(false)
|
||||
})
|
||||
|
||||
it("should fail for invalid Swagger 2.0 version values", function () {
|
||||
expect(isSwagger2Shorthand("2.0-rc0")).toEqual(false)
|
||||
expect(isSwagger2Shorthand("3.0")).toEqual(false)
|
||||
expect(isSwagger2Shorthand("3.0.")).toEqual(false)
|
||||
expect(isSwagger2Shorthand("2.1")).toEqual(false)
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -55,7 +55,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -89,7 +89,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -126,7 +126,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -170,7 +170,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -211,7 +211,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -266,7 +266,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -320,7 +320,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
@@ -349,7 +349,7 @@ describe("OAS3 plugin - state", function() {
|
||||
return {
|
||||
specSelectors: {
|
||||
specJson: () => {
|
||||
return fromJS({ openapi: "3.0.0" })
|
||||
return fromJS({ openapi: "3.0.4" })
|
||||
},
|
||||
isOAS3: () => true,
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ describe("oas3 plugin - auth extensions - wrapSelectors", function(){
|
||||
getState: () => new Map(),
|
||||
specSelectors: {
|
||||
specJson: () => fromJS({
|
||||
openapi: "3.0.0"
|
||||
openapi: "3.0.4"
|
||||
}),
|
||||
isOAS3: () => true,
|
||||
securityDefinitions: () => {
|
||||
|
||||
@@ -8,7 +8,7 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
openapi: "3.0.0",
|
||||
openapi: "3.0.4",
|
||||
components: {
|
||||
schemas: {
|
||||
a: {
|
||||
@@ -48,7 +48,7 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
openapi: "3.0.0"
|
||||
openapi: "3.0.4"
|
||||
})
|
||||
|
||||
const system = {
|
||||
@@ -71,7 +71,7 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
openapi: "3.0.0",
|
||||
openapi: "3.0.4",
|
||||
components: {
|
||||
schemas: "..."
|
||||
}
|
||||
|
||||
@@ -5,12 +5,33 @@ const isOAS31Shorthand = (version) => isOAS31(fromJS({
|
||||
openapi: version
|
||||
}))
|
||||
|
||||
describe("isOAS31", function () {
|
||||
it("should recognize valid OAS31 version values", function () {
|
||||
|
||||
describe("isOAS30", function () {
|
||||
it("should recognize valid OAS3 version values", function () {
|
||||
expect(isOAS31Shorthand("3.1.0")).toEqual(true)
|
||||
expect(isOAS31Shorthand("3.1.1")).toEqual(true)
|
||||
expect(isOAS31Shorthand("3.1.12")).toEqual(true)
|
||||
expect(isOAS31Shorthand("3.2.0")).toEqual(false)
|
||||
expect(isOAS31Shorthand("3.0.0-rc0")).toEqual(false)
|
||||
expect(isOAS31Shorthand("3.1.25")).toEqual(true)
|
||||
})
|
||||
|
||||
it("should fail for invalid OAS3 version values", function () {
|
||||
expect(isOAS31Shorthand("3.1")).toEqual(false)
|
||||
expect(isOAS31Shorthand("3.1.")).toEqual(false)
|
||||
expect(isOAS31Shorthand("3.1.01")).toEqual(false)
|
||||
expect(isOAS31Shorthand("2.0")).toEqual(false)
|
||||
|
||||
})
|
||||
|
||||
it("should gracefully fail for non-string values", function () {
|
||||
expect(isOAS31Shorthand(3.0)).toEqual(false)
|
||||
expect(isOAS31Shorthand(3)).toEqual(false)
|
||||
expect(isOAS31Shorthand({})).toEqual(false)
|
||||
expect(isOAS31Shorthand(null)).toEqual(false)
|
||||
})
|
||||
|
||||
it("should gracefully fail when `openapi` field is missing", function () {
|
||||
expect(isOAS31(fromJS({
|
||||
openApi: "3.1.0"
|
||||
}))).toEqual(false)
|
||||
expect(isOAS31Shorthand(null)).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import { fromJS } from "immutable"
|
||||
import { fromJSOrdered } from "core/utils"
|
||||
import {
|
||||
@@ -7,6 +6,7 @@ import {
|
||||
contentTypeValues,
|
||||
operationScheme,
|
||||
specJsonWithResolvedSubtrees,
|
||||
operations,
|
||||
producesOptionsFor,
|
||||
operationWithMeta,
|
||||
parameterWithMeta,
|
||||
@@ -460,6 +460,7 @@ describe("specJsonWithResolvedSubtrees", function(){
|
||||
},
|
||||
security: [
|
||||
{
|
||||
// eslint-disable-next-line camelcase
|
||||
petstore_auth: [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
@@ -1216,6 +1217,23 @@ describe("taggedOperations", function () {
|
||||
}
|
||||
})
|
||||
})
|
||||
it("should gracefully handle a malformed paths defined as array", function () {
|
||||
const state = fromJS({
|
||||
json: {
|
||||
tags: [null],
|
||||
paths:[
|
||||
{
|
||||
"/users": null,
|
||||
"get": null
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const result = operations(state)
|
||||
|
||||
expect(result.toJS()).toEqual([])
|
||||
})
|
||||
})
|
||||
describe("isMediaTypeSchemaPropertiesEqual", () => {
|
||||
const stateSingleMediaType = fromJS({
|
||||
@@ -1400,11 +1418,11 @@ describe("validationErrors", function() {
|
||||
"query.with.dot.hash": {
|
||||
errors: [
|
||||
{
|
||||
error: "Value must be an integer",
|
||||
error: "Value must be an integer",
|
||||
propKey: "id"
|
||||
},
|
||||
{
|
||||
error: "Value must be a string",
|
||||
{
|
||||
error: "Value must be a string",
|
||||
propKey: "name"
|
||||
}
|
||||
]
|
||||
@@ -1418,12 +1436,12 @@ describe("validationErrors", function() {
|
||||
"query.arrayWithObjects.hash": {
|
||||
errors: [
|
||||
{
|
||||
error: "Parameter string value must be valid JSON",
|
||||
error: "Parameter string value must be valid JSON",
|
||||
index: 0
|
||||
},
|
||||
{
|
||||
{
|
||||
error: {
|
||||
error: "Value must be a string",
|
||||
error: "Value must be a string",
|
||||
propKey: "name"
|
||||
},
|
||||
index: 1
|
||||
|
||||
Reference in New Issue
Block a user