From 2238244f0065f4e240aac4ebc3146a7688cc332f Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Nov 2022 14:37:40 -0500 Subject: [PATCH] Fixed snapshot test --- .../loadAndBundleSpec.test.ts.snap | 2406 +++++++++++++++++ src/utils/__tests__/loadAndBundleSpec.test.ts | 6 + 2 files changed, 2412 insertions(+) diff --git a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap index c2b2e7cc..3a3305d6 100644 --- a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap +++ b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap @@ -1,5 +1,2411 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`#loadAndBundleSpec should load And Bundle Spec demo/openapi.yaml 1`] = ` +Object { + "components": Object { + "examples": Object { + "Order": Object { + "value": Object { + "complete": false, + "quantity": 1, + "shipDate": "2018-10-19T16:46:45Z", + "status": "placed", + }, + }, + }, + "requestBodies": Object { + "Pet": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "allOf": Array [ + Object { + "description": "My Pet", + "title": "Pettie", + }, + Object { + "$ref": "#/components/schemas/Pet", + }, + ], + }, + }, + "application/xml": Object { + "schema": Object { + "properties": Object { + "name": Object { + "description": "hooray", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + "description": "Pet object that needs to be added to the store", + "required": true, + }, + "UserArray": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "items": Object { + "$ref": "#/components/schemas/User", + }, + "type": "array", + }, + }, + }, + "description": "List of user object", + "required": true, + }, + }, + "schemas": Object { + "ApiResponse": Object { + "properties": Object { + "code": Object { + "format": "int32", + "type": "integer", + }, + "message": Object { + "type": "string", + }, + "type": Object { + "type": "string", + }, + }, + "type": "object", + }, + "Cat": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Pet", + }, + Object { + "properties": Object { + "huntingSkill": Object { + "default": "lazy", + "description": "The measured skill for hunting", + "enum": Array [ + "clueless", + "lazy", + "adventurous", + "aggressive", + ], + "example": "adventurous", + "type": "string", + }, + }, + "required": Array [ + "huntingSkill", + ], + "type": "object", + }, + ], + "description": "A representation of a cat", + }, + "Category": Object { + "properties": Object { + "id": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Id", + }, + ], + "description": "Category ID", + }, + "name": Object { + "description": "Category name", + "minLength": 1, + "type": "string", + }, + "sub": Object { + "description": "Test Sub Category", + "properties": Object { + "prop1": Object { + "description": "Dumb Property", + "type": "string", + }, + }, + "type": "object", + }, + }, + "type": "object", + "xml": Object { + "name": "Category", + }, + }, + "Dog": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Pet", + }, + Object { + "properties": Object { + "packSize": Object { + "default": 1, + "description": "The size of the pack the dog is from", + "format": "int32", + "minimum": 1, + "type": "integer", + }, + }, + "required": Array [ + "packSize", + ], + "type": "object", + }, + ], + "description": "A representation of a dog", + }, + "HoneyBee": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Pet", + }, + Object { + "properties": Object { + "honeyPerDay": Object { + "description": "Average amount of honey produced per day in ounces", + "example": 3.14, + "multipleOf": 0.01, + "type": "number", + }, + }, + "required": Array [ + "honeyPerDay", + ], + "type": "object", + }, + ], + "description": "A representation of a honey bee", + }, + "Id": Object { + "format": "int64", + "readOnly": true, + "type": "integer", + }, + "Order": Object { + "properties": Object { + "complete": Object { + "default": false, + "description": "Indicates whenever order was completed or not", + "readOnly": true, + "type": "boolean", + }, + "id": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Id", + }, + ], + "description": "Order ID", + }, + "petId": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Id", + }, + ], + "description": "Pet ID", + }, + "quantity": Object { + "default": 1, + "format": "int32", + "minimum": 1, + "type": "integer", + }, + "requestId": Object { + "description": "Unique Request Id", + "type": "string", + "writeOnly": true, + }, + "shipDate": Object { + "description": "Estimated ship date", + "format": "date-time", + "type": "string", + }, + "status": Object { + "description": "Order Status", + "enum": Array [ + "placed", + "approved", + "delivered", + ], + "type": "string", + }, + }, + "type": "object", + "xml": Object { + "name": "Order", + }, + }, + "Pet": Object { + "discriminator": Object { + "mapping": Object { + "bee": "#/components/schemas/HoneyBee", + "cat": "#/components/schemas/Cat", + "dog": "#/components/schemas/Dog", + }, + "propertyName": "petType", + }, + "properties": Object { + "category": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Category", + }, + ], + "description": "Categories this pet belongs to", + }, + "friend": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Pet", + }, + ], + }, + "id": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Id", + }, + ], + "description": "Pet ID", + "externalDocs": Object { + "description": "Find more info here", + "url": "https://example.com", + }, + }, + "name": Object { + "description": "The name given to a pet", + "example": "Guru", + "type": "string", + }, + "petType": Object { + "description": "Type of a pet", + "type": "string", + }, + "photoUrls": Object { + "description": "The list of URL to a cute photos featuring pet", + "items": Object { + "format": "url", + "type": "string", + }, + "maxItems": 20, + "type": "array", + "xml": Object { + "name": "photoUrl", + "wrapped": true, + }, + }, + "status": Object { + "description": "Pet status in the store", + "enum": Array [ + "available", + "pending", + "sold", + ], + "type": "string", + }, + "tags": Object { + "description": "Tags attached to the pet", + "items": Object { + "$ref": "#/components/schemas/Tag", + }, + "minItems": 1, + "type": "array", + "xml": Object { + "name": "tag", + "wrapped": true, + }, + }, + }, + "required": Array [ + "name", + "photoUrls", + ], + "type": "object", + "xml": Object { + "name": "Pet", + }, + }, + "Tag": Object { + "properties": Object { + "id": Object { + "allOf": Array [ + Object { + "$ref": "#/components/schemas/Id", + }, + ], + "description": "Tag ID", + }, + "name": Object { + "description": "Tag name", + "minLength": 1, + "type": "string", + }, + }, + "type": "object", + "xml": Object { + "name": "Tag", + }, + }, + "User": Object { + "properties": Object { + "addresses": Object { + "additionalItems": Object { + "type": "string", + }, + "items": Array [ + Object { + "properties": Object { + "city": Object { + "minLength": 0, + "type": "string", + }, + "country": Object { + "minLength": 0, + "type": "string", + }, + "street": Object { + "description": "includes build/apartment number", + "minLength": 0, + "type": "string", + }, + }, + "type": "object", + }, + Object { + "type": "number", + }, + ], + "maxLength": 10, + "minItems": 0, + "type": "array", + }, + "email": Object { + "description": "User email address", + "example": "john.smith@example.com", + "format": "email", + "type": "string", + }, + "firstName": Object { + "description": "User first name", + "example": "John", + "minLength": 1, + "type": "string", + }, + "id": Object { + "$ref": "#/components/schemas/Id", + }, + "lastName": Object { + "description": "User last name", + "example": "Smith", + "minLength": 1, + "type": "string", + }, + "password": Object { + "description": "User password, MUST contain a mix of upper and lower case letters, as well as digits", + "example": "drowssaP123", + "format": "password", + "minLength": 8, + "pattern": "/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/", + "type": "string", + }, + "pet": Object { + "oneOf": Array [ + Object { + "$ref": "#/components/schemas/Pet", + }, + Object { + "$ref": "#/components/schemas/Tag", + }, + ], + }, + "phone": Object { + "description": "User phone number in international format", + "example": "+1-202-555-0192", + "pattern": "/^\\\\+(?:[0-9]-?){6,14}[0-9]$/", + "type": "string", + }, + "userStatus": Object { + "description": "User status", + "format": "int32", + "type": "integer", + }, + "username": Object { + "description": "User supplied username", + "example": "John78", + "minLength": 4, + "type": "string", + }, + }, + "type": "object", + "xml": Object { + "name": "User", + }, + }, + }, + "securitySchemes": Object { + "api_key": Object { + "description": "For this sample, you can use the api key \`special-key\` to test the authorization filters. +", + "in": "header", + "name": "api_key", + "type": "apiKey", + }, + "petstore_auth": Object { + "description": "Get access to data while protecting your account credentials. +OAuth2 is also a safer and more secure way to give you access. +", + "flows": Object { + "implicit": Object { + "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "scopes": Object { + "read:pets": "read your pets", + "write:pets": "modify pets in your account", + }, + }, + }, + "type": "oauth2", + }, + }, + }, + "externalDocs": Object { + "description": "Find out how to create Github repo for your OpenAPI spec.", + "url": "https://github.com/Rebilly/generator-openapi-repo", + }, + "info": Object { + "contact": Object { + "email": "apiteam@swagger.io", + "name": "API Support", + "url": "https://github.com/Redocly/redoc", + }, + "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. + +# Introduction +This API is documented in **OpenAPI format** and is based on +[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. +It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) +tool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard +OpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/main/docs/redoc-vendor-extensions.md). + +# OpenAPI Specification +This API is documented in **OpenAPI format** and is based on +[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. +It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) +tool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard +OpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/main/docs/redoc-vendor-extensions.md). + +# Cross-Origin Resource Sharing +This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). +And that allows cross-domain communication from the browser. +All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site. + +# Authentication + +Petstore offers two forms of authentication: + - API Key + - OAuth2 +OAuth2 - an open protocol to allow secure authorization in a simple +and standard method from web, mobile and desktop applications. + + +", + "license": Object { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html", + }, + "termsOfService": "http://swagger.io/terms/", + "title": "Swagger Petstore", + "version": "1.1.0", + "x-logo": Object { + "altText": "Petstore logo", + "url": "https://redocly.github.io/redoc/petstore-logo.png", + }, + }, + "openapi": "3.0.0", + "paths": Object { + "/accounts/{accountId}/tnoptions": Object { + "get": Object { + "description": "Retrieve a list of the TN Option orders that are associated with the account. A maximum of 1,000 orders can be retrieved per request. If no date range or specific query parameter (marked by * below) is provided, the order results will be limited to the last two years.", + "operationId": "GetTnOptionOrders", + "parameters": Array [ + Object { + "description": "The status of the TN Option order being searched for.", + "example": "PROCESSING", + "in": "query", + "name": "status", + "required": false, + "schema": Object { + "items": Object { + "type": "string", + }, + "type": "array", + }, + }, + Object { + "description": "* A Telephone Number (TN) that is referenced in the order.", + "example": "9199918388", + "in": "query", + "name": "tn", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "* The Customer Order ID is an ID assigned by the account owner to provide a reference number for the TN Option order.", + "example": "ABCCorp12345", + "in": "query", + "name": "customerOrderId", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "For Date-based searches, the starting date of a date range (inclusive) that will be used to find TN Option Orders that were modified within the date range. It is in the form yyyy-MM-dd.", + "example": "2013-10-22", + "in": "query", + "name": "modifiedDateFrom", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "For Date-based searches, the ending date of a date range (inclusive) that will be used to find TN Option Orders that were modified within the date range. It is in the form yyyy-MM-dd.", + "example": "2013-10-25", + "in": "query", + "name": "modifiedDateTo", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "Checks the order's creation date against this value. Orders that have a creation date after this date will be included. Format is yyyy-MM-dd.", + "example": "2013-10-22", + "in": "query", + "name": "createdDateFrom", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "Checks the order's creation date against this value. Orders that have a creation date before this date will be included. Format is yyyy-MM-dd.", + "example": "2013-10-25", + "in": "query", + "name": "createdDateTo", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "Checks the order's last modified date against this value. Orders that have a modification date after this date will be included. Format is yyyy-MM-dd.", + "example": "2013-10-25", + "in": "query", + "name": "lastModifiedAfter", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "This is the user-name of the user that last modified the TN Option Order.", + "example": "smckinnon", + "in": "query", + "name": "lastModifiedBy", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "* This search parameter represents the internal Bandwidth Dashboard API ID that has been assigned to the TN Option Order. This parameter is the first few characters of the internal ID - the entire ID does not need to be specified.", + "example": "ed1c0bed-e2", + "in": "query", + "name": "orderIdFragment", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "If set to true, a list of order details will be displayed instead the summary information.", + "in": "query", + "name": "orderDetails", + "required": false, + "schema": Object { + "type": "boolean", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + + 2 + + 14 + 2 + jbm + 2016-01-15T12:01:14.363Z + 2016-01-15T12:01:14.324Z + tn_option + FAILED + ddbdc72e-dc27-490c-904e-d0c11291b095 + + + 14 + 3 + jbm + 2016-01-15T11:22:58.969Z + 2016-01-15T11:22:58.789Z + tn_option + COMPLETE + 409033ee-88ec-43e3-85f3-538f30733963 + + + + + 2 + + 2016-01-15T12:01:14.324Z + 14 + jbm + ddbdc72e-dc27-490c-904e-d0c11291b095 + 2016-01-15T12:01:14.363Z + FAILED + + + 10digit + 10digit + testUser1 + 6042661720 + on + true + on + sip:+12345678901@1.2.3.4:5060 + + 2018551020 + + + + off + false + off + + 2018551025 + + + + + + 5076 + Telephone number is not available. + 2018551025 + + + 5076 + Telephone number is not available. + 2018551020 + + + + + 2016-01-15T11:22:58.789Z + 14 + jbm + 409033ee-88ec-43e3-85f3-538f30733963 + 2016-01-15T11:22:58.969Z + COMPLETE + + + on + + 2174101601 + + + + off + + 2174101602 + + + + systemdefault + + 2174101603 + + + + + + +", + }, + }, + }, + }, + "description": "The descriptive payload for the TN Option Orders query provides a broad range of information about the TN Option Orders found by the query, including the data associated with the order, the state of the order, and details about the order if it was successful.", + }, + "404": Object { + "content": Object { + "application/xml": Object {}, + }, + "description": "Not Found. If any errors are found in the processing of the query string a 404 will be returned. Note that parameters that are not recognized are not considered errors, and are just ignored. +", + }, + }, + "summary": "Retrieve list TN Option orders", + "tags": Array [ + "Tn Option", + ], + }, + "post": Object { + "description": "Create TN Option order to assign line features to the telephone number.

Attribute description:", + "operationId": "CreateTnOptionOrder", + "requestBody": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + TnOptionOrder1 + + + 10digit + 10digit + testUser1 + 6042661720 + on + a1b2c3 + true + on + sip:+12345678901@1.2.3.4:5060 + + M + campaignId010 + asSpecified + + + 2018551020 + + + + off + false + off + + + 6105552502 + 1 + 100 + + + sip:clarkkent@dailyplanet.com + 2 + 100 + + + 192.168.20.21 + 3 + 50 + + + 7075552509 + 3 + 50 + + + myhost.bandwidth.example + 4 + 100 + + asSpecified + + + 2018551025 + + + + true + + 2018551026 + + + +", + }, + }, + }, + }, + }, + "responses": Object { + "201": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + + 2016-01-15T12:01:14.324Z + 14 + jbm + ddbdc72e-dc27-490c-904e-d0c11291b095 + 2016-01-15T12:01:14.324Z + RECEIVED + + + 10digit + 10digit + testUser1 + 6042661720 + on + true + on + + 2018551020 + + + + off + false + off + + 2018551025 + + + + + +", + }, + }, + }, + }, + "description": "Created", + }, + "400": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + + 5081 + Number Format 'wrong' is invalid. + +", + }, + }, + }, + }, + "description": "Bad Request A 400 response Indicates that the order could not be created. Error text and an error code will be provided in the ErrorList element.", + }, + "409": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + + 5200 + Origination route plan is not enabled for the account. + +", + }, + }, + }, + }, + "description": "Conflict. Error text and an error code will be provided in the ErrorList element.", + }, + }, + "summary": "Create TN Option order", + "tags": Array [ + "Tn Option", + ], + }, + }, + "/accounts/{accountId}/tnoptions/{orderid}": Object { + "get": Object { + "description": "Retrieve information about a TN Option Order with specified ID.", + "operationId": "GetTnOptionOrder", + "parameters": Array [ + Object { + "description": "", + "in": "path", + "name": "orderid", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + 2016-01-15T11:22:58.789Z + 14 + jbm + 409033ee-88ec-43e3-85f3-538f30733963 + 2016-01-15T11:22:58.969Z + COMPLETE + + + on + on + + 2174101601 + + + + off + + 2174101602 + + + + systemdefault + sip:+12345678901@1.2.3.4:5060 + + 2174101603 + + + + + + + 2174101601 + SMS is already Enabled or number is in processing. + + +", + }, + }, + }, + }, + "description": "The descriptive payload for the TN Option Orders query provides a broad range of information about the TN Option Order identified in the URL. Included amongst the information is: ", + }, + "404": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "example": Object { + "value": " + + + The resource does not exist + +", + }, + }, + }, + }, + "description": "Not found. The order id does not exist in the system.", + }, + }, + "summary": "Retrieve TN Option order", + "tags": Array [ + "Tn Option", + ], + }, + }, + "/accounts/{accountId}/tnoptions/{orderid}/history": Object { + "get": Object { + "description": "Retrieve the history information associated with an order.", + "operationId": "GetOrderHistory", + "parameters": Array [ + Object { + "description": "", + "in": "path", + "name": "orderid", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/xml": Object { + "examples": Object { + "application/xml": Object { + "value": " + + + 2020-09-17T08:56:39.607Z + Order has been received by the system. + admin + received + + + 2020-09-17T08:56:39.743Z + Order processing has started. + admin + processing + + + 2020-09-17T08:56:39.820Z + Order is complete. + admin + complete + +", + }, + }, + }, + }, + "description": "The history payload is a set of history records, each of which contains: + + + +
OrderDateThe date that the order history event happened
StatusThe new state of the TN Option order - RECEIVED, PROCESSING, COMPLETE, PARTIAL, FAILED
NoteA Note or additional information included with the state change
AuthorThe user id that implemented the state change

", + }, + "404": Object { + "content": Object { + "application/xml": Object {}, + }, + "description": "Not found. The order id does not exist in the system.", + }, + }, + "summary": "Retrieve TN Option order history", + "tags": Array [ + "Tn Option", + ], + }, + }, + "/pet": Object { + "parameters": Array [ + Object { + "description": "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US", + "example": "en-US", + "in": "header", + "name": "Accept-Language", + "required": false, + "schema": Object { + "default": "en-AU", + "type": "string", + }, + }, + Object { + "description": "Some cookie", + "in": "cookie", + "name": "cookieParam", + "required": true, + "schema": Object { + "format": "int64", + "type": "integer", + }, + }, + ], + "post": Object { + "description": "Add new pet to the store inventory.", + "operationId": "addPet", + "requestBody": Object { + "$ref": "#/components/requestBodies/Pet", + }, + "responses": Object { + "405": Object { + "description": "Invalid input", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Add a new pet to the store", + "tags": Array [ + "pet", + ], + "x-codeSamples": Array [ + Object { + "lang": "C#", + "source": "PetStore.v1.Pet pet = new PetStore.v1.Pet(); +pet.setApiKey(\\"your api key\\"); +pet.petType = PetStore.v1.Pet.TYPE_DOG; +pet.name = \\"Rex\\"; +// set other fields +PetStoreResponse response = pet.create(); +if (response.statusCode == HttpStatusCode.Created) +{ + // Successfully created +} +else +{ + // Something wrong -- check response for errors + Console.WriteLine(response.getRawResponse()); +} +", + }, + Object { + "lang": "PHP", + "source": "$form = new \\\\PetStore\\\\Entities\\\\Pet(); +$form->setPetType(\\"Dog\\"); +$form->setName(\\"Rex\\"); +// set other fields +try { + $pet = $client->pets()->create($form); +} catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); +} +", + }, + ], + }, + "put": Object { + "description": "", + "operationId": "updatePet", + "requestBody": Object { + "$ref": "#/components/requestBodies/Pet", + }, + "responses": Object { + "400": Object { + "description": "Invalid ID supplied", + }, + "404": Object { + "description": "Pet not found", + }, + "405": Object { + "description": "Validation exception", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Update an existing pet", + "tags": Array [ + "pet", + ], + "x-codeSamples": Array [ + Object { + "lang": "PHP", + "source": "$form = new \\\\PetStore\\\\Entities\\\\Pet(); +$form->setPetId(1); +$form->setPetType(\\"Dog\\"); +$form->setName(\\"Rex\\"); +// set other fields +try { + $pet = $client->pets()->update($form); +} catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); +} +", + }, + ], + }, + }, + "/pet/findByStatus": Object { + "get": Object { + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": Array [ + Object { + "description": "Status values that need to be considered for filter", + "in": "query", + "name": "status", + "required": true, + "schema": Object { + "items": Object { + "default": "available", + "enum": Array [ + "available", + "pending", + "sold", + ], + "type": "string", + }, + "maxItems": 3, + "minItems": 1, + "type": "array", + }, + "style": "form", + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "items": Object { + "$ref": "#/components/schemas/Pet", + }, + "type": "array", + }, + }, + "application/xml": Object { + "schema": Object { + "items": Object { + "$ref": "#/components/schemas/Pet", + }, + "type": "array", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "description": "Invalid status value", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Finds Pets by status", + "tags": Array [ + "pet", + ], + }, + }, + "/pet/findByTags": Object { + "get": Object { + "deprecated": true, + "description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": Array [ + Object { + "description": "Tags to filter by", + "in": "query", + "name": "tags", + "required": true, + "schema": Object { + "items": Object { + "type": "string", + }, + "type": "array", + }, + "style": "form", + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "items": Object { + "$ref": "#/components/schemas/Pet", + }, + "type": "array", + }, + }, + "application/xml": Object { + "schema": Object { + "items": Object { + "$ref": "#/components/schemas/Pet", + "maxItems": 111, + }, + "maxItems": 999, + "type": "array", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "description": "Invalid tag value", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Finds Pets by tags", + "tags": Array [ + "pet", + ], + }, + }, + "/pet/{petId}": Object { + "delete": Object { + "description": "", + "operationId": "deletePet", + "parameters": Array [ + Object { + "example": "Bearer ", + "in": "header", + "name": "api_key", + "required": false, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "Pet id to delete", + "in": "path", + "name": "petId", + "required": true, + "schema": Object { + "format": "int64", + "type": "integer", + }, + }, + ], + "responses": Object { + "400": Object { + "description": "Invalid pet value", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Deletes a pet", + "tags": Array [ + "pet", + ], + }, + "get": Object { + "description": "Returns a single pet", + "operationId": "getPetById", + "parameters": Array [ + Object { + "deprecated": true, + "description": "ID of pet to return", + "in": "path", + "name": "petId", + "required": true, + "schema": Object { + "format": "int64", + "type": "integer", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/Pet", + }, + }, + "application/xml": Object { + "schema": Object { + "$ref": "#/components/schemas/Pet", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "description": "Invalid ID supplied", + }, + "404": Object { + "description": "Pet not found", + }, + }, + "security": Array [ + Object { + "api_key": Array [], + }, + ], + "summary": "Find pet by ID", + "tags": Array [ + "pet", + ], + }, + "post": Object { + "description": "", + "operationId": "updatePetWithForm", + "parameters": Array [ + Object { + "description": "ID of pet that needs to be updated", + "in": "path", + "name": "petId", + "required": true, + "schema": Object { + "format": "int64", + "type": "integer", + }, + }, + ], + "requestBody": Object { + "content": Object { + "application/x-www-form-urlencoded": Object { + "schema": Object { + "properties": Object { + "name": Object { + "description": "Updated name of the pet", + "type": "string", + }, + "status": Object { + "description": "Updated status of the pet", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + }, + "responses": Object { + "405": Object { + "description": "Invalid input", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "Updates a pet in the store with form data", + "tags": Array [ + "pet", + ], + }, + }, + "/pet/{petId}/uploadImage": Object { + "post": Object { + "description": "", + "operationId": "uploadFile", + "parameters": Array [ + Object { + "description": "ID of pet to update", + "in": "path", + "name": "petId", + "required": true, + "schema": Object { + "format": "int64", + "type": "integer", + }, + }, + ], + "requestBody": Object { + "content": Object { + "application/octet-stream": Object { + "schema": Object { + "format": "binary", + "type": "string", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/ApiResponse", + }, + }, + }, + "description": "successful operation", + }, + }, + "security": Array [ + Object { + "petstore_auth": Array [ + "write:pets", + "read:pets", + ], + }, + ], + "summary": "uploads an image", + "tags": Array [ + "pet", + ], + }, + }, + "/store/inventory": Object { + "get": Object { + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "additionalProperties": Object { + "format": "int32", + "type": "integer", + }, + "minProperties": 2, + "type": "object", + }, + }, + }, + "description": "successful operation", + }, + }, + "security": Array [ + Object { + "api_key": Array [], + }, + ], + "summary": "Returns pet inventories by status", + "tags": Array [ + "store", + ], + }, + }, + "/store/order": Object { + "post": Object { + "description": "", + "operationId": "placeOrder", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/Order", + }, + }, + }, + "description": "order placed for purchasing the pet", + "required": true, + }, + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/Order", + }, + }, + "application/xml": Object { + "schema": Object { + "$ref": "#/components/schemas/Order", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "content": Object { + "application/json": Object { + "example": Object { + "message": "Invalid Order", + "status": 400, + }, + }, + }, + "description": "Invalid Order", + }, + }, + "summary": "Place an order for a pet", + "tags": Array [ + "store", + ], + }, + }, + "/store/order/{orderId}": Object { + "delete": Object { + "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId": "deleteOrder", + "parameters": Array [ + Object { + "description": "ID of the order that needs to be deleted", + "in": "path", + "name": "orderId", + "required": true, + "schema": Object { + "minimum": 1, + "type": "string", + }, + }, + ], + "responses": Object { + "400": Object { + "description": "Invalid ID supplied", + }, + "404": Object { + "description": "Order not found", + }, + }, + "summary": "Delete purchase order by ID", + "tags": Array [ + "store", + ], + }, + "get": Object { + "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId": "getOrderById", + "parameters": Array [ + Object { + "description": "ID of pet that needs to be fetched", + "in": "path", + "name": "orderId", + "required": true, + "schema": Object { + "format": "int64", + "maximum": 5, + "minimum": 1, + "type": "integer", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/Order", + }, + }, + "application/xml": Object { + "schema": Object { + "$ref": "#/components/schemas/Order", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "description": "Invalid ID supplied", + }, + "404": Object { + "description": "Order not found", + }, + }, + "summary": "Find purchase order by ID", + "tags": Array [ + "store", + ], + }, + }, + "/store/subscribe": Object { + "post": Object { + "callbacks": Object { + "orderDelivered": Object { + "http://notificationServer.com?url={$request.body#/callbackUrl}&event={$request.body#/eventName}": Object { + "post": Object { + "deprecated": true, + "description": "A callback triggered every time an Order is delivered to the recipient", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "orderId": Object { + "example": "123", + "type": "string", + }, + "timestamp": Object { + "example": "2018-10-19T16:46:45Z", + "format": "date-time", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "description": "Callback successfully processed and no retries will be performed", + }, + }, + "summary": "Order delivered", + }, + }, + }, + "orderInProgress": Object { + "{$request.body#/callbackUrl}?event={$request.body#/eventName}": Object { + "post": Object { + "description": "A callback triggered every time an Order is updated status to \\"inProgress\\" (Description)", + "externalDocs": Object { + "description": "Find out more", + "url": "https://more-details.com/demo", + }, + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "orderId": Object { + "example": "123", + "type": "string", + }, + "status": Object { + "example": "inProgress", + "type": "string", + }, + "timestamp": Object { + "example": "2018-10-19T16:46:45Z", + "format": "date-time", + "type": "string", + }, + }, + "type": "object", + }, + }, + "application/xml": Object { + "example": " + + 123 + inProgress + 2018-10-19T16:46:45Z + +", + "schema": Object { + "properties": Object { + "orderId": Object { + "example": "123", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "someProp": Object { + "example": "123", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + "description": "Callback successfully processed and no retries will be performed", + }, + "299": Object { + "description": "Response for cancelling subscription", + }, + "500": Object { + "description": "Callback processing failed and retries will be performed", + }, + }, + "summary": "Order in Progress (Summary)", + "x-codeSamples": Array [ + Object { + "lang": "C#", + "source": "PetStore.v1.Pet pet = new PetStore.v1.Pet(); +pet.setApiKey(\\"your api key\\"); +pet.petType = PetStore.v1.Pet.TYPE_DOG; +pet.name = \\"Rex\\"; +// set other fields +PetStoreResponse response = pet.create(); +if (response.statusCode == HttpStatusCode.Created) +{ + // Successfully created +} +else +{ + // Something wrong -- check response for errors + Console.WriteLine(response.getRawResponse()); +} +", + }, + Object { + "lang": "PHP", + "source": "$form = new \\\\PetStore\\\\Entities\\\\Pet(); +$form->setPetType(\\"Dog\\"); +$form->setName(\\"Rex\\"); +// set other fields +try { + $pet = $client->pets()->create($form); +} catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); +} +", + }, + ], + }, + "put": Object { + "description": "Order in Progress (Only Description)", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "orderId": Object { + "example": "123", + "type": "string", + }, + "status": Object { + "example": "inProgress", + "type": "string", + }, + "timestamp": Object { + "example": "2018-10-19T16:46:45Z", + "format": "date-time", + "type": "string", + }, + }, + "type": "object", + }, + }, + "application/xml": Object { + "example": " + + 123 + inProgress + 2018-10-19T16:46:45Z + +", + "schema": Object { + "properties": Object { + "orderId": Object { + "example": "123", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "someProp": Object { + "example": "123", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + "description": "Callback successfully processed and no retries will be performed", + }, + }, + "servers": Array [ + Object { + "description": "Operation level server 1 (Operation override)", + "url": "//callback-url.operation-level/v1", + }, + Object { + "description": "Operation level server 2 (Operation override)", + "url": "//callback-url.operation-level/v2", + }, + ], + }, + "servers": Array [ + Object { + "description": "Path level server 1", + "url": "//callback-url.path-level/v1", + }, + Object { + "description": "Path level server 2", + "url": "//callback-url.path-level/v2", + }, + ], + }, + }, + "orderShipped": Object { + "{$request.body#/callbackUrl}?event={$request.body#/eventName}": Object { + "post": Object { + "description": "Very long description +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor +incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis +nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu +fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in +culpa qui officia deserunt mollit anim id est laborum. +", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "estimatedDeliveryDate": Object { + "example": "2018-11-11T16:00:00Z", + "format": "date-time", + "type": "string", + }, + "orderId": Object { + "example": "123", + "type": "string", + }, + "timestamp": Object { + "example": "2018-10-19T16:46:45Z", + "format": "date-time", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "description": "Callback successfully processed and no retries will be performed", + }, + }, + }, + }, + }, + }, + "description": "Add subscription for a store events", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "callbackUrl": Object { + "description": "This URL will be called by the server when the desired event will occur", + "example": "https://myserver.com/send/callback/here", + "format": "uri", + "type": "string", + }, + "eventName": Object { + "description": "Event name for the subscription", + "enum": Array [ + "orderInProgress", + "orderShipped", + "orderDelivered", + ], + "example": "orderInProgress", + "type": "string", + }, + }, + "required": Array [ + "callbackUrl", + "eventName", + ], + "type": "object", + }, + }, + }, + }, + "responses": Object { + "201": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "properties": Object { + "subscriptionId": Object { + "example": "AAA-123-BBB-456", + "type": "string", + }, + }, + "type": "object", + }, + }, + }, + "description": "Subscription added", + }, + }, + "summary": "Subscribe to the Store events", + "tags": Array [ + "store", + ], + }, + }, + "/user": Object { + "post": Object { + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/User", + }, + }, + }, + "description": "Created user object", + "required": true, + }, + "responses": Object { + "default": Object { + "description": "successful operation", + }, + }, + "summary": "Create user", + "tags": Array [ + "user", + ], + }, + }, + "/user/createWithArray": Object { + "post": Object { + "description": "", + "operationId": "createUsersWithArrayInput", + "requestBody": Object { + "$ref": "#/components/requestBodies/UserArray", + }, + "responses": Object { + "default": Object { + "description": "successful operation", + }, + }, + "summary": "Creates list of users with given input array", + "tags": Array [ + "user", + ], + }, + }, + "/user/createWithList": Object { + "post": Object { + "description": "", + "operationId": "createUsersWithListInput", + "requestBody": Object { + "$ref": "#/components/requestBodies/UserArray", + }, + "responses": Object { + "default": Object { + "description": "successful operation", + }, + }, + "summary": "Creates list of users with given input array", + "tags": Array [ + "user", + ], + }, + }, + "/user/login": Object { + "get": Object { + "description": "", + "operationId": "loginUser", + "parameters": Array [ + Object { + "description": "The user name for login", + "in": "query", + "name": "username", + "required": true, + "schema": Object { + "type": "string", + }, + }, + Object { + "description": "The password for login in clear text", + "in": "query", + "name": "password", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "examples": Object { + "response": Object { + "value": "OK", + }, + }, + "schema": Object { + "type": "string", + }, + }, + "application/xml": Object { + "examples": Object { + "response": Object { + "value": " OK ", + }, + }, + "schema": Object { + "type": "string", + }, + }, + "text/plain": Object { + "examples": Object { + "response": Object { + "value": "OK", + }, + }, + }, + }, + "description": "successful operation", + "headers": Object { + "X-Expires-After": Object { + "description": "date in UTC when token expires", + "schema": Object { + "format": "date-time", + "type": "string", + }, + }, + "X-Rate-Limit": Object { + "description": "calls per hour allowed by the user", + "schema": Object { + "format": "int32", + "type": "integer", + }, + }, + }, + }, + "400": Object { + "description": "Invalid username/password supplied", + }, + }, + "summary": "Logs user into the system", + "tags": Array [ + "user", + ], + }, + }, + "/user/logout": Object { + "get": Object { + "description": "", + "operationId": "logoutUser", + "responses": Object { + "default": Object { + "description": "successful operation", + }, + }, + "summary": "Logs out current logged in user session", + "tags": Array [ + "user", + ], + }, + }, + "/user/{username}": Object { + "delete": Object { + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", + "parameters": Array [ + Object { + "description": "The name that needs to be deleted", + "in": "path", + "name": "username", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "responses": Object { + "400": Object { + "description": "Invalid username supplied", + }, + "404": Object { + "description": "User not found", + }, + }, + "summary": "Delete user", + "tags": Array [ + "user", + ], + }, + "get": Object { + "description": "", + "operationId": "getUserByName", + "parameters": Array [ + Object { + "description": "The name that needs to be fetched. Use user1 for testing. ", + "in": "path", + "name": "username", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "responses": Object { + "200": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/User", + }, + }, + "application/xml": Object { + "schema": Object { + "$ref": "#/components/schemas/User", + }, + }, + }, + "description": "successful operation", + }, + "400": Object { + "description": "Invalid username supplied", + }, + "404": Object { + "description": "User not found", + }, + }, + "summary": "Get user by user name", + "tags": Array [ + "user", + ], + }, + "put": Object { + "description": "This can only be done by the logged in user.", + "operationId": "updateUser", + "parameters": Array [ + Object { + "description": "name that need to be deleted", + "in": "path", + "name": "username", + "required": true, + "schema": Object { + "type": "string", + }, + }, + ], + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/User", + }, + }, + }, + "description": "Updated user object", + "required": true, + }, + "responses": Object { + "400": Object { + "description": "Invalid user supplied", + }, + "404": Object { + "description": "User not found", + }, + }, + "summary": "Updated user", + "tags": Array [ + "user", + ], + }, + }, + }, + "security": Array [ + Object {}, + ], + "servers": Array [ + Object { + "description": "Default server", + "url": "//petstore.swagger.io/v2", + }, + Object { + "description": "Sandbox server", + "url": "//petstore.swagger.io/sandbox", + }, + ], + "tags": Array [ + Object { + "description": "Everything about your Pets", + "name": "pet", + }, + Object { + "description": "Everything about your TN Options", + "name": "Tn Option", + }, + Object { + "description": "Access to Petstore orders", + "name": "store", + }, + Object { + "description": "Operations about user", + "name": "user", + }, + Object { + "description": " +", + "name": "pet_model", + "x-displayName": "The Pet Model", + }, + Object { + "description": " +", + "name": "store_model", + "x-displayName": "The Order Model", + }, + ], + "x-tagGroups": Array [ + Object { + "name": "General", + "tags": Array [ + "pet", + "store", + "Tn Option", + ], + }, + Object { + "name": "User Management", + "tags": Array [ + "user", + ], + }, + Object { + "name": "Models", + "tags": Array [ + "pet_model", + "store_model", + ], + }, + ], + "x-webhooks": Object { + "newPet": Object { + "post": Object { + "description": "Information about a new pet in the systems", + "operationId": "newPet", + "requestBody": Object { + "content": Object { + "application/json": Object { + "schema": Object { + "$ref": "#/components/schemas/Pet", + }, + }, + }, + }, + "responses": Object { + "200": Object { + "description": "Return a 200 status to indicate that the data was received successfully", + }, + }, + "summary": "New pet", + "tags": Array [ + "pet", + ], + }, + }, + }, +} +`; + exports[`#loadAndBundleSpec should load And Bundle Spec demo/openapi-3-1.yaml 1`] = ` Object { "components": Object { diff --git a/src/utils/__tests__/loadAndBundleSpec.test.ts b/src/utils/__tests__/loadAndBundleSpec.test.ts index 2972ac5e..4abb3a6c 100644 --- a/src/utils/__tests__/loadAndBundleSpec.test.ts +++ b/src/utils/__tests__/loadAndBundleSpec.test.ts @@ -4,6 +4,12 @@ import { resolve } from 'path'; import { loadAndBundleSpec } from '../loadAndBundleSpec'; describe('#loadAndBundleSpec', () => { + it('should load And Bundle Spec demo/openapi.yaml', async () => { + const spec = yaml.load(readFileSync(resolve(__dirname, '../../../demo/openapi.yaml'), 'utf-8')); + const bundledSpec = await loadAndBundleSpec(spec); + expect(bundledSpec).toMatchSnapshot(); + }); + it('should load And Bundle Spec demo/openapi-3-1.yaml', async () => { const spec = yaml.load( readFileSync(resolve(__dirname, '../../../demo/openapi-3-1.yaml'), 'utf-8'),