UNPKG

fastify-openapi-glue

Version:

generate a fastify configuration from an openapi specification

363 lines (362 loc) 6.45 kB
{ "swagger": "2.0", "info": { "title": "Test swagger", "description": "testing the fastify swagger api", "version": "0.1.0" }, "host": "localhost", "basePath": "/v2", "schemes": ["http"], "consumes": ["application/json"], "produces": ["application/json"], "security": [ { "skipped": [] } ], "paths": { "/pathParam/{id}": { "get": { "operationId": "getPathParam", "summary": "Test path parameters", "parameters": [ { "name": "id", "in": "path", "required": true, "type": "integer" } ], "responses": { "200": { "description": "ok" } } } }, "/queryParam": { "get": { "operationId": "getQueryParam", "summary": "Test query parameters", "parameters": [ { "in": "query", "name": "int1", "type": "integer" }, { "in": "query", "name": "int2", "type": "integer" } ], "responses": { "200": { "description": "ok" } }, "x-tap-ok": true } }, "/headerParam": { "get": { "operationId": "getHeaderParam", "summary": "Test header parameters", "parameters": [ { "in": "header", "name": "X-Request-ID", "type": "string" } ], "responses": { "200": { "description": "ok" } } } }, "/bodyParam": { "post": { "operationId": "postBodyParam", "summary": "Test body parameters", "parameters": [ { "name": "str1", "in": "body", "required": true, "schema": { "$ref": "#/definitions/bodyObject" } } ], "responses": { "200": { "description": "ok" } } } }, "/noParam": { "get": { "operationId": "getNoParam", "summary": "Test without parameters", "responses": { "200": { "description": "ok" } } } }, "/noOperationId/{id}": { "get": { "summary": "Test missing operationid", "parameters": [ { "name": "id", "in": "path", "required": true, "type": "integer" } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } } } } }, "/responses": { "get": { "operationId": "getResponse", "summary": "Test response serialization", "parameters": [ { "in": "query", "name": "replyType", "type": "string" } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } } } } }, "/operationSecurity": { "get": { "operationId": "testOperationSecurity", "summary": "Test security handling", "security": [ { "api_key": [] }, { "skipped": [] }, { "failing": [] } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } }, "401": { "description": "unauthorized", "schema": { "$ref": "#/definitions/errorObject" } } } } }, "/operationSecurityUsingAnd": { "get": { "operationId": "testOperationSecurityUsingAnd", "summary": "Test security handling AND functionality", "security": [ { "api_key": ["and"], "skipped": ["works"] } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } }, "401": { "description": "unauthorized", "schema": { "$ref": "#/definitions/errorObject" } } } } }, "/operationSecurityWithParameter": { "get": { "operationId": "testOperationSecurityWithParameter", "summary": "Test security handling", "security": [ { "api_key": [] }, { "skipped": ["skipped"] }, { "failing": [] } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } }, "401": { "description": "unauthorized", "schema": { "$ref": "#/definitions/errorObject" } } } } }, "/operationSecurityEmptyHandler": { "get": { "operationId": "testOperationSecurity", "summary": "Test security handling", "security": [ {}, { "failing": [] } ], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } }, "401": { "description": "unauthorized", "schema": { "$ref": "#/definitions/errorObject" } } } } }, "/operationSecurityOverrideWithNoSecurity": { "get": { "operationId": "testOperationSecurity", "summary": "Test security handling", "security": [], "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } }, "401": { "description": "unauthorized", "schema": { "$ref": "#/definitions/errorObject" } } } } }, "/operationWithFastifyConfigExtension": { "get": { "operationId": "operationWithFastifyConfigExtension", "summary": "Test fastify config extension", "x-fastify-config": { "rawBody": true }, "responses": { "200": { "description": "ok", "schema": { "$ref": "#/definitions/responseObject" } } } } }, "/emptyBodySchema": { "get": { "operationId": "emptyBodySchema", "summary": "Empty body schema", "responses": { "204": { "description": "Empty" }, "302": { "description": "Empty" } } } } }, "definitions": { "bodyObject": { "type": "object", "properties": { "str1": { "type": "string" } }, "required": ["str1"] }, "responseObject": { "type": "object", "properties": { "response": { "type": "string" } }, "required": ["response"] }, "errorObject": { "type": "object", "properties": { "error": { "type": "string" }, "statusCode": { "type": "integer" } } } }, "securityDefinitions": { "api_key": { "type": "apiKey", "in": "header", "name": "X-API-Key" }, "skipped": { "type": "basic" } } }