fix: path item $ref rendering (#4381)
* WIP: trigger resolution of Path Item $ref on spec load * fix(dev-server): don't open localhost in a browser * preserve key order when merging specJson with specResolvedSubtrees * remove stray `debugger`
This commit is contained in:
1035
test/core/plugins/spec/assets/petstore.json
Normal file
1035
test/core/plugins/spec/assets/petstore.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
/* eslint-env mocha */
|
||||
import expect from "expect"
|
||||
import { fromJS } from "immutable"
|
||||
import { fromJSOrdered } from "core/utils"
|
||||
import {
|
||||
parameterValues,
|
||||
contentTypeValues,
|
||||
@@ -9,6 +10,8 @@ import {
|
||||
operationConsumes
|
||||
} from "corePlugins/spec/selectors"
|
||||
|
||||
import Petstore from "./assets/petstore.json"
|
||||
|
||||
describe("spec plugin - selectors", function(){
|
||||
|
||||
describe("parameterValue", function(){
|
||||
@@ -311,7 +314,6 @@ describe("spec plugin - selectors", function(){
|
||||
|
||||
})
|
||||
|
||||
|
||||
describe("specJsonWithResolvedSubtrees", function(){
|
||||
|
||||
it("should return a correctly merged tree", function(){
|
||||
@@ -360,5 +362,93 @@ describe("spec plugin - selectors", function(){
|
||||
}
|
||||
})
|
||||
})
|
||||
it("should preserve initial map key ordering", function(){
|
||||
// Given
|
||||
let state = fromJSOrdered({
|
||||
json: Petstore,
|
||||
resolvedSubtrees: {
|
||||
paths: {
|
||||
"/pet/{petId}": {
|
||||
post: {
|
||||
tags: [
|
||||
"pet"
|
||||
],
|
||||
summary: "Updates a pet in the store with form data",
|
||||
description: "",
|
||||
operationId: "updatePetWithForm",
|
||||
consumes: [
|
||||
"application/x-www-form-urlencoded"
|
||||
],
|
||||
produces: [
|
||||
"application/xml",
|
||||
"application/json"
|
||||
],
|
||||
parameters: [
|
||||
{
|
||||
name: "petId",
|
||||
"in": "path",
|
||||
description: "ID of pet that needs to be updated",
|
||||
required: true,
|
||||
type: "integer",
|
||||
format: "int64"
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
"in": "formData",
|
||||
description: "Updated name of the pet",
|
||||
required: false,
|
||||
type: "string"
|
||||
},
|
||||
{
|
||||
name: "status",
|
||||
"in": "formData",
|
||||
description: "Updated status of the pet",
|
||||
required: false,
|
||||
type: "string"
|
||||
}
|
||||
],
|
||||
responses: {
|
||||
"405": {
|
||||
description: "Invalid input"
|
||||
}
|
||||
},
|
||||
security: [
|
||||
{
|
||||
petstore_auth: [
|
||||
"write:pets",
|
||||
"read:pets"
|
||||
]
|
||||
}
|
||||
],
|
||||
__originalOperationId: "updatePetWithForm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// When
|
||||
let result = specJsonWithResolvedSubtrees(state)
|
||||
|
||||
// Then
|
||||
const correctOrder = [
|
||||
"/pet",
|
||||
"/pet/findByStatus",
|
||||
"/pet/findByTags",
|
||||
"/pet/{petId}",
|
||||
"/pet/{petId}/uploadImage",
|
||||
"/store/inventory",
|
||||
"/store/order",
|
||||
"/store/order/{orderId}",
|
||||
"/user",
|
||||
"/user/createWithArray",
|
||||
"/user/createWithList",
|
||||
"/user/login",
|
||||
"/user/logout",
|
||||
"/user/{username}"
|
||||
]
|
||||
expect(state.getIn(["json", "paths"]).keySeq().toJS()).toEqual(correctOrder)
|
||||
expect(result.getIn(["paths"]).keySeq().toJS()).toEqual(correctOrder)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user