forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding "clean" Swagger validation test (Azure#1254)
* Fixing minor validation errors - Fixing description rule to allow references to define a description - Fixing AutoRest logging output to avoid throwing NRE when an error is logged without an exception - Changing the message that gets output for validation errors to make it more useful * Adding a validation test that validates a clean spec - This verifies that rules are not unintentionally being returned for specs that don't have the issue. If a rule is added that causes this test to fail, this spec should be updated so that it passes those rules (and verify that the rule isn't being triggered inadvertently)
- Loading branch information
Showing
5 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
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
206 changes: 206 additions & 0 deletions
206
src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/clean-complex-spec.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,206 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"version": "1.0.0", | ||
"title": "Swagger Petstore", | ||
"license": { | ||
"name": "MIT" | ||
} | ||
}, | ||
"host": "petstore.swagger.io", | ||
"basePath": "/v1", | ||
"schemes": [ | ||
"http" | ||
], | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"paths": { | ||
"/pets": { | ||
"get": { | ||
"summary": "List all pets", | ||
"operationId": "listPets", | ||
"tags": [ | ||
"pets" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "limit", | ||
"in": "query", | ||
"description": "How many items to return at one time (max 100)", | ||
"required": false, | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "An paged array of pets", | ||
"headers": { | ||
"x-next": { | ||
"type": "string", | ||
"description": "A link to the next page of responses" | ||
} | ||
}, | ||
"schema": { | ||
"$ref": "#/definitions/Pets" | ||
} | ||
}, | ||
"default": { | ||
"description": "unexpected error", | ||
"schema": { | ||
"$ref": "#/definitions/Error" | ||
} | ||
} | ||
} | ||
}, | ||
"post": { | ||
"summary": "Create a pet", | ||
"operationId": "createPets", | ||
"tags": [ | ||
"pets" | ||
], | ||
"responses": { | ||
"201": { | ||
"description": "Null response" | ||
}, | ||
"default": { | ||
"description": "unexpected error", | ||
"schema": { | ||
"$ref": "#/definitions/Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/pets/{petId}": { | ||
"get": { | ||
"summary": "Info for a specific pet", | ||
"operationId": "showPetById", | ||
"tags": [ | ||
"pets" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "petId", | ||
"in": "path", | ||
"required": true, | ||
"description": "The id of the pet to retrieve", | ||
"type": "string" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Expected response to a valid request", | ||
"schema": { | ||
"$ref": "#/definitions/Pets" | ||
} | ||
}, | ||
"default": { | ||
"description": "unexpected error", | ||
"schema": { | ||
"$ref": "#/definitions/Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/foo": { | ||
"get": { | ||
"operationId": "Foo_Get", | ||
"responses": { | ||
"default": { | ||
"$ref": "#/responses/FooResponse" | ||
} | ||
} | ||
}, | ||
"post": { | ||
"operationId": "Foo_Post", | ||
"parameters": [ | ||
{ | ||
"in": "body", | ||
"name": "fooPost", | ||
"schema": { | ||
"type": "object", | ||
"description": "A foo object" | ||
}, | ||
"description": "Foo body parameter" | ||
}, | ||
{ | ||
"$ref": "#/parameters/FooQueryParam" | ||
} | ||
], | ||
"responses": { | ||
"default": { | ||
"$ref": "#/responses/FooResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"parameters": { | ||
"FooQueryParam": { | ||
"in": "query", | ||
"name": "FooQueryParam", | ||
"description": "Query parameter for Foo operation", | ||
"type": "string" | ||
} | ||
}, | ||
"responses": { | ||
"FooResponse": { | ||
"description": "Response for Foo" | ||
} | ||
}, | ||
"definitions": { | ||
"Pet": { | ||
"required": [ | ||
"id", | ||
"name" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"format": "int64", | ||
"description": "The pet id" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"description": "The pet name" | ||
}, | ||
"tag": { | ||
"type": "string", | ||
"description": "The pet tag" | ||
} | ||
}, | ||
"description": "A pet" | ||
}, | ||
"Pets": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Pet" | ||
}, | ||
"description": "A set of pets" | ||
}, | ||
"Error": { | ||
"required": [ | ||
"code", | ||
"message" | ||
], | ||
"properties": { | ||
"code": { | ||
"type": "integer", | ||
"format": "int32", | ||
"description": "The code of the error" | ||
}, | ||
"message": { | ||
"type": "string", | ||
"description": "The message of the error" | ||
} | ||
}, | ||
"description": "An error result" | ||
} | ||
} | ||
} |
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