fix: path-item $ref produces/consumes inheritance (via #5049)

* implement a selector for consumes options

* fix incorrect comment, test names

* add `consumesOptionsFor` selector

* use `consumesOptionsFor` and drop `operationConsumes`
This commit is contained in:
kyle
2018-11-23 23:24:11 +01:00
committed by GitHub
parent 2977c93840
commit 971c6f7536
7 changed files with 400 additions and 39 deletions

View File

@@ -0,0 +1,17 @@
---
paths:
findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
parameters:
- name: "status"
in: "body"
schema:
type: string
responses:
200:
description: ok

View File

@@ -0,0 +1,44 @@
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
produces:
- application/json
- application/xml
- text/csv
consumes:
- application/json
- application/xml
- text/csv
schemes:
- "https"
- "http"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
405:
description: "Invalid input"
/pet/findByStatus:
$ref: "status.yaml#/paths/findByStatus"

View File

@@ -0,0 +1,32 @@
import repeat from "lodash/repeat"
describe("#5043: path-level $ref path items should inherit global consumes/produces", () => {
it("should render consumes options correctly", () => {
cy
.visit("/?url=/documents/bugs/5043/swagger.yaml")
.get("#operations-pet-findPetsByStatus")
.click()
.get(".try-out__btn")
.click()
.get(".content-type")
.contains("application/json")
.get(".content-type")
.contains("application/xml")
.get(".content-type")
.contains("text/csv")
})
it("should render produces options correctly", () => {
cy
.visit("/?url=/documents/bugs/5043/swagger.yaml")
.get("#operations-pet-findPetsByStatus")
.click()
.get(".try-out__btn")
.click()
.get(".body-param-content-type select")
.contains("application/json")
.get(".body-param-content-type select")
.contains("application/xml")
.get(".body-param-content-type select")
.contains("text/csv")
})
})