refactor(oas31): concentrate OpenAPI 3.1.0 code to separate plugin (#8475)

Refs #8474
This commit is contained in:
Vladimír Gorej
2023-03-16 12:05:19 +01:00
committed by GitHub
parent ceccb218d3
commit 8b274414ab
35 changed files with 929 additions and 699 deletions

View File

@@ -1,7 +1,7 @@
import { fromJS } from "immutable"
import { isOAS3, isSwagger2 } from "corePlugins/oas3/helpers"
import { isOAS30, isSwagger2 } from "corePlugins/oas3/helpers"
const isOAS3Shorthand = (version) => isOAS3(fromJS({
const isOAS3Shorthand = (version) => isOAS30(fromJS({
openapi: version
}))
@@ -13,7 +13,7 @@ describe("isOAS3", 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.11111")).toEqual(true)
expect(isOAS3Shorthand("3.0.11111")).toEqual(false)
expect(isOAS3Shorthand("3.0.0-rc0")).toEqual(true)
})
@@ -31,7 +31,7 @@ describe("isOAS3", function () {
})
it("should gracefully fail when `openapi` field is missing", function () {
expect(isOAS3(fromJS({
expect(isOAS30(fromJS({
openApi: "3.0.0"
}))).toEqual(false)
expect(isOAS3Shorthand(null)).toEqual(false)
@@ -41,7 +41,7 @@ describe("isOAS3", function () {
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(true)
expect(isSwagger2Shorthand("2.0-rc0")).toEqual(false)
})
it("should fail for invalid Swagger 2.0 version values", function () {

View File

@@ -26,7 +26,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -55,7 +56,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -88,7 +90,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -124,7 +127,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -167,7 +171,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -207,7 +212,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -261,7 +267,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -314,7 +321,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}
@@ -342,7 +350,8 @@ describe("OAS3 plugin - state", function() {
specSelectors: {
specJson: () => {
return fromJS({ openapi: "3.0.0" })
}
},
isOAS3: () => true,
}
}
}

View File

@@ -17,6 +17,7 @@ describe("oas3 plugin - auth extensions - wrapSelectors", function(){
specJson: () => fromJS({
openapi: "3.0.0"
}),
isOAS3: () => true,
securityDefinitions: () => {
return fromJS({
"oauth2AuthorizationCode": {

View File

@@ -1,8 +1,5 @@
import { fromJS } from "immutable"
import {
definitions
} from "corePlugins/oas3/spec-extensions/wrap-selectors"
import { definitions } from "corePlugins/oas3/spec-extensions/wrap-selectors"
describe("oas3 plugin - spec extensions - wrapSelectors", function(){
@@ -28,6 +25,7 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
getSystem: () => system,
specSelectors: {
specJson: () => spec,
isOAS3: () => true,
}
}
@@ -57,6 +55,7 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
getSystem: () => system,
specSelectors: {
specJson: () => spec,
isOAS3: () => true,
}
}
@@ -82,7 +81,8 @@ describe("oas3 plugin - spec extensions - wrapSelectors", function(){
getSystem: () => system,
specSelectors: {
specJson: () => spec,
}
isOAS3: () => true,
},
}
// When