-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(openapi/validate): cleanup 🧹 (#520)
* chore(deps): install ora * chore: add ora to dependabot and reformat * feat: add spinner for file validation * feat: initial registry upload function * refactor: move ora opts into shared function * refactor: use shared ora opts in new function also * feat: first pass at rewriting openapi command to support new flow - also i realphabetized the imports * chore: making the spinners spin * test: refactor existing tests to work with new flow * test: fix error code in test I tried running recreating this and the API responds with a 4xx, not a 5xx in this case. * test: adding coverage for PUT endpoint error handling * chore: move two tests under describe block it was bugging me how we had two tests that were uncategorized and clearly fit under the "upload" describe block (definitely my bad) * test: add coverage for if registry endpoint fails * chore: fix typo in test * chore: remove unnecessary error handling This error handling was unnecessary, as shown in the test I added. The validation section above it flags this, so there theoretically shouldn't be any errors bundling that wouldn't already be flagged in the validation section above. * chore: test coverage in ora opts * chore: oops * chore: spinner language * test: remove unused prompt handler * chore: add test TODO after noodling with this for a bit I couldn't figure it out 😞 so adding a TODO so someone can hopefully write a test for this.
- Loading branch information
1 parent
6fd6fc4
commit 66e8efe
Showing
7 changed files
with
445 additions
and
101 deletions.
There are no files selected for viewing
179 changes: 179 additions & 0 deletions
179
__tests__/__fixtures__/invalid-ref-oas/external-components.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
{ | ||
"requestBodies": { | ||
"Pet": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/schemas/Pet" | ||
} | ||
}, | ||
"application/xml": { | ||
"schema": { | ||
"$ref": "#/schemas/Pet" | ||
} | ||
} | ||
}, | ||
"description": "Pet object that needs to be added to the store", | ||
"required": true | ||
} | ||
}, | ||
"schemas": { | ||
"Order": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"petId": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"quantity": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"shipDate": { | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"status": { | ||
"type": "string", | ||
"description": "Order Status", | ||
"enum": [ | ||
"placed", | ||
"approved", | ||
"delivered" | ||
] | ||
}, | ||
"complete": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
}, | ||
"xml": { | ||
"name": "Order" | ||
} | ||
}, | ||
"Category": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"xml": { | ||
"name": "Category" | ||
} | ||
}, | ||
"User": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"username": { | ||
"type": "string" | ||
}, | ||
"firstName": { | ||
"type": "string" | ||
}, | ||
"lastName": { | ||
"type": "string" | ||
}, | ||
"email": { | ||
"type": "string" | ||
}, | ||
"password": { | ||
"type": "string" | ||
}, | ||
"phone": { | ||
"type": "string" | ||
}, | ||
"userStatus": { | ||
"type": "integer", | ||
"format": "int32", | ||
"description": "User Status" | ||
} | ||
}, | ||
"xml": { | ||
"name": "User" | ||
} | ||
}, | ||
"Tag": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"xml": { | ||
"name": "Tag" | ||
} | ||
}, | ||
"Pet": { | ||
"type": "object", | ||
"required": [ | ||
"name", | ||
"photoUrls" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64", | ||
"default": 40, | ||
"example": 25 | ||
}, | ||
"category": { | ||
"$ref": "#/schemas/Category" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"example": "doggie" | ||
}, | ||
"photoUrls": { | ||
"type": "array", | ||
"xml": { | ||
"name": "photoUrl", | ||
"wrapped": true | ||
}, | ||
"items": { | ||
"type": "string", | ||
"example": "https://example.com/photo.png" | ||
} | ||
}, | ||
"tags": { | ||
"type": "array", | ||
"xml": { | ||
"name": "tag", | ||
"wrapped": true | ||
}, | ||
"items": { | ||
"$ref": "#/schemas/Tag" | ||
} | ||
}, | ||
"status": { | ||
"type": "string", | ||
"description": "pet status in the store", | ||
"enum": [ | ||
"available", | ||
"pending", | ||
"sold" | ||
] | ||
} | ||
}, | ||
"xml": { | ||
"name": "Pet" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "1.0.0", | ||
"title": "Example petstore to demo our handling of external $ref pointers" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://petstore.swagger.io/v2" | ||
} | ||
], | ||
"paths": { | ||
"/pet": { | ||
"post": { | ||
"tags": ["pet"], | ||
"summary": "Add a new pet to the store", | ||
"description": "", | ||
"operationId": "addPet", | ||
"requestBody": { | ||
"$ref": "__tests__/__fixtures__/ref-oas/external-components.json#/requestBodies/Petty" | ||
}, | ||
"responses": { | ||
"405": { | ||
"description": "Invalid input" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"petstore_auth": ["write:pets", "read:pets"] | ||
} | ||
] | ||
}, | ||
"put": { | ||
"tags": ["pet"], | ||
"summary": "Update an existing pet", | ||
"description": "", | ||
"operationId": "updatePet", | ||
"requestBody": { | ||
"$ref": "__tests__/__fixtures__/ref-oas/external-components.json#/requestBodies/Petty" | ||
}, | ||
"responses": { | ||
"400": { | ||
"description": "Invalid ID supplied" | ||
}, | ||
"404": { | ||
"description": "Pet not found" | ||
}, | ||
"405": { | ||
"description": "Validation exception" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"petstore_auth": ["write:pets", "read:pets"] | ||
} | ||
] | ||
} | ||
}, | ||
"/pet/{petId}": { | ||
"get": { | ||
"tags": ["pet"], | ||
"summary": "Find pet by ID", | ||
"description": "Returns a single pet", | ||
"operationId": "getPetById", | ||
"parameters": [ | ||
{ | ||
"name": "petId", | ||
"in": "path", | ||
"description": "ID of pet to return", | ||
"required": true, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "successful operation", | ||
"content": { | ||
"application/xml": { | ||
"schema": { | ||
"$ref": "__tests__/__fixtures__/ref-oas/external-components.json#/schemas/Petty" | ||
} | ||
}, | ||
"application/json": { | ||
"schema": { | ||
"$ref": "__tests__/__fixtures__/ref-oas/external-components.json#/schemas/Petty" | ||
} | ||
} | ||
} | ||
}, | ||
"400": { | ||
"description": "Invalid ID supplied" | ||
}, | ||
"404": { | ||
"description": "Pet not found" | ||
}, | ||
"default": { | ||
"description": "successful response" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"api_key": [] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"components": { | ||
"securitySchemes": { | ||
"petstore_auth": { | ||
"type": "oauth2", | ||
"flows": { | ||
"implicit": { | ||
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog", | ||
"scopes": { | ||
"write:pets": "modify pets in your account", | ||
"read:pets": "read your pets" | ||
} | ||
} | ||
} | ||
}, | ||
"api_key": { | ||
"type": "apiKey", | ||
"name": "api_key", | ||
"in": "header" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.