Project: KICS (Provisioning / Security & Compliance)
File: 2cf35b40-ded3-43d6-9633-c8dcc8bcc822.md

title: Operation Example Mismatch Produces MimeType hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 2cf35b40-ded3-43d6-9633-c8dcc8bcc822 Query name: Operation Example Mismatch Produces MimeType Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Example should match one of MimeTypes on 'produces'. It is important to know that, if a 'produces' is declared on operation it will override global 'produces'<br> ```json title="Positive test num. 1 - json file" hl_lines="34" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "parameters": [ { "name": "limit2", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } ], "operationId": "listVersionsv2", "summary": "List API versions", "produces": [ "application/json" ], "responses": { "200": { "description": "OK", "examples": { "application/json": { "id": 38, "title": "Versions" }, "text/csv": "id,title 38,Versions" } } } } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="27" swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: parameters: name: limit2 in: body description: max records to return required: true schema: type: integer operationId: listVersionsv2 summary: List API versions produces: application/json responses: '200': description: OK examples: application/json: id: 38 title: Versions text/csv: id,title 38,Versions parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer ``` ```json title="Negative test num. 1 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version":

}, "paths": { "/": { "get": { "parameters": [ { "name": "limit2", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } ], "operationId": "listVersionsv2", "summary": "List API versions", "produces": [ "application/json", "text/csv" ], "responses": { "200": { "description": "OK", "examples": { "application/json": { "id": 38, "title": "Versions" }, "text/csv": "id,title 38,Versions" } } } } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } } } ``` ```json title="Negative test num. 2 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "parameters": [ { "name": "limit2", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } ], "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "OK", "examples": { "application/json": { "id": 38, "title": "Versions" }, "text/csv": "id,title 38,Versions" } } } } } }, "produces": [ "application/json", "text/csv" ], "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } } } ``` ```yaml title="Negative test num. 3 - yaml file" swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: parameters: name: limit2 in: body description: max records to return required: true schema: type: integer operationId: listVersionsv2 summary: List API versions produces: application/json text/csv responses: '200': description: OK examples: application/json: id: 38 title: Versions text/csv: id,title 38,Versions parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: parameters: name: limit2 in: body description: max records to return required: true schema: type: integer operationId: listVersionsv2 summary: List API versions responses: '200': description: OK examples: application/json: id: 38 title: Versions text/csv: id,title 38,Versions produces: application/json text/csv parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer ``` </details>