From 504e23aa7405a92f295d8c862ae9ff49f20790da Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Wed, 14 Jun 2017 20:34:34 +0530 Subject: [PATCH 01/64] Test dir refactor, test_crud fix, minor bug fixes --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 From 27b40d1d16d0755b60dec9e01f1b3173e66db606 Mon Sep 17 00:00:00 2001 From: chrizandr Date: Sat, 22 Jul 2017 22:32:46 +0530 Subject: [PATCH 02/64] New tests for Hydrus, dynamic DB Connectivity using App context, changes to docs, small bug fixes. --- dummy_data.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 dummy_data.py diff --git a/dummy_data.py b/dummy_data.py new file mode 100644 index 0000000..6639f57 --- /dev/null +++ b/dummy_data.py @@ -0,0 +1,20 @@ +"""Creates a dummy object for a given class based on the API Documentation.""" + +import random +import string +import pdb + + +def gen_dummy_object(class_, doc): + """Create a dummy object based on the definitions in the API Doc.""" + object_ = { + "@type": class_ + } + if class_ in doc.parsed_classes: + for prop in doc.parsed_classes[class_]["class"].supportedProperty: + if "vocab:" in prop.prop: + prop_class = doc.parsed_classes[prop.prop.replace("vocab:", "")]["class"] + object_[prop.title] = gen_dummy_object(prop_class, doc) + else: + object_[prop.title] = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + return object_ From 52217733bfbf8ecb857872c5b896830f4a967045 Mon Sep 17 00:00:00 2001 From: chrizandr Date: Fri, 28 Jul 2017 23:53:59 +0530 Subject: [PATCH 03/64] Rearranging getters and setters to utils, removing unused code. --- dummy_data.py | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 dummy_data.py diff --git a/dummy_data.py b/dummy_data.py deleted file mode 100644 index 6639f57..0000000 --- a/dummy_data.py +++ /dev/null @@ -1,20 +0,0 @@ -"""Creates a dummy object for a given class based on the API Documentation.""" - -import random -import string -import pdb - - -def gen_dummy_object(class_, doc): - """Create a dummy object based on the definitions in the API Doc.""" - object_ = { - "@type": class_ - } - if class_ in doc.parsed_classes: - for prop in doc.parsed_classes[class_]["class"].supportedProperty: - if "vocab:" in prop.prop: - prop_class = doc.parsed_classes[prop.prop.replace("vocab:", "")]["class"] - object_[prop.title] = gen_dummy_object(prop_class, doc) - else: - object_[prop.title] = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) - return object_ From 0916f857d9b2e84808aa20a52ca5b2a1c61c8875 Mon Sep 17 00:00:00 2001 From: chrizandr Date: Sat, 29 Jul 2017 20:08:06 +0530 Subject: [PATCH 04/64] Fixing sample. --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 From 25d10c3515a4107a1ffc2ebf3a950b2e1055c699 Mon Sep 17 00:00:00 2001 From: ayushiiit Date: Tue, 13 Feb 2018 23:48:10 +0530 Subject: [PATCH 05/64] Create __init__.py --- __init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ + From d923bb7b24db9c75cd1d7aaf5bd26e39d91c066f Mon Sep 17 00:00:00 2001 From: ayushiiit Date: Tue, 13 Feb 2018 23:48:10 +0530 Subject: [PATCH 06/64] Create __init__.py --- __init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ + From 380b1bff92b62b02b590e38f771a3eb9326c7058 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 27 May 2018 12:56:00 +0530 Subject: [PATCH 07/64] added samples --- hydra_doc_sample.py | 738 ++++++++++++++++++++++++++++++++++++++++++++ openapi_sample.yaml | 700 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1438 insertions(+) create mode 100644 hydra_doc_sample.py create mode 100644 openapi_sample.yaml diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py new file mode 100644 index 0000000..65664d0 --- /dev/null +++ b/hydra_doc_sample.py @@ -0,0 +1,738 @@ +""" +Generated API Documentation for Server API using server_doc_gen.py.""" + +doc = { + "@context": { + "ApiDocumentation": "hydra:ApiDocumentation", + "description": "hydra:description", + "domain": { + "@id": "rdfs:domain", + "@type": "@id" + }, + "expects": { + "@id": "hydra:expects", + "@type": "@id" + }, + "hydra": "http://www.w3.org/ns/hydra/core#", + "label": "rdfs:label", + "method": "hydra:method", + "possibleStatus": "hydra:possibleStatus", + "property": { + "@id": "hydra:property", + "@type": "@id" + }, + "range": { + "@id": "rdfs:range", + "@type": "@id" + }, + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "readonly": "hydra:readonly", + "required": "hydra:required", + "returns": { + "@id": "hydra:returns", + "@type": "@id" + }, + "statusCode": "hydra:statusCode", + "statusCodes": "hydra:statusCodes", + "subClassOf": { + "@id": "rdfs:subClassOf", + "@type": "@id" + }, + "supportedClass": "hydra:supportedClass", + "supportedOperation": "hydra:supportedOperation", + "supportedProperty": "hydra:supportedProperty", + "title": "hydra:title", + "vocab": "petstore.swagger.io/v2/vocab#", + "writeonly": "hydra:writeonly" + }, + "@id": "petstore.swagger.io/v2/vocab", + "@type": "ApiDocumentation", + "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.", + "possibleStatus": [], + "supportedClass": [ + { + "@id": "vocab:Order", + "@type": "hydra:Class", + "description": "this is def", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:petId", + "readonly": "true", + "required": "false", + "title": "petId", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:quantity", + "readonly": "true", + "required": "false", + "title": "quantity", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:shipDate", + "readonly": "true", + "required": "false", + "title": "shipDate", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:complete", + "readonly": "true", + "required": "false", + "title": "complete", + "writeonly": "true" + } + ], + "title": "Order" + }, + { + "@id": "vocab:User", + "@type": "hydra:Class", + "description": "User", + "supportedOperation": [ + { + "@type": "http://schema.org/FindAction", + "expects": "vocab:User", + "method": "post", + "possibleStatus": { + "default": { + "description": "successful operation" + } + }, + "returns": "null", + "title": "Create user" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:username", + "readonly": "true", + "required": "false", + "title": "username", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:firstName", + "readonly": "true", + "required": "false", + "title": "firstName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:lastName", + "readonly": "true", + "required": "false", + "title": "lastName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:email", + "readonly": "true", + "required": "false", + "title": "email", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:password", + "readonly": "true", + "required": "false", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", + "writeonly": "true" + } + ], + "title": "User" + }, + { + "@id": "vocab:Category", + "@type": "hydra:Class", + "description": "Category", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + } + ], + "title": "Category" + }, + { + "@id": "vocab:Tag", + "@type": "hydra:Class", + "description": "Tag", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + } + ], + "title": "Tag" + }, + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/FindAction", + "expects": "vocab:Pet", + "method": "post", + "possibleStatus": { + "405": { + "description": "Invalid input" + } + }, + "returns": "null", + "title": "Add a new pet to the store" + }, + { + "@type": "http://schema.org/FindAction", + "expects": "vocab:Pet", + "method": "put", + "possibleStatus": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "returns": "null", + "title": "Update an existing pet" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:category", + "readonly": "true", + "required": "false", + "title": "category", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:photoUrls", + "readonly": "true", + "required": "false", + "title": "photoUrls", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:tags", + "readonly": "true", + "required": "false", + "title": "tags", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + } + ], + "title": "Pet" + }, + { + "@id": "vocab:ApiResponse", + "@type": "hydra:Class", + "description": "ApiResponse", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:code", + "readonly": "true", + "required": "false", + "title": "code", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:type", + "readonly": "true", + "required": "false", + "title": "type", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:message", + "readonly": "true", + "required": "false", + "title": "message", + "writeonly": "true" + } + ], + "title": "ApiResponse" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "vocab:EntryPoint", + "@type": "hydra:Class", + "description": "The main entry point or homepage of the API.", + "supportedOperation": [ + { + "@id": "_:entry_point", + "@type": "http://schema.org/FindAction", + "description": "The APIs main entry point.", + "expects": "null", + "method": "GET", + "returns": "null", + "statusCodes": "vocab:EntryPoint" + } + ], + "supportedProperty": [], + "title": "EntryPoint" + } + ], + "title": "Swagger Petstore" +} diff --git a/openapi_sample.yaml b/openapi_sample.yaml new file mode 100644 index 0000000..e426e6b --- /dev/null +++ b/openapi_sample.yaml @@ -0,0 +1,700 @@ +swagger: '2.0' +info: + 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.' + version: 1.0.0 + title: Swagger Petstore + termsOfService: 'http://swagger.io/terms/' + contact: + email: apiteam@swagger.io + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' +host: petstore.swagger.io +basePath: /v2 +tags: + - name: pet + description: Everything about your Pets + externalDocs: + description: Find out more + url: 'http://swagger.io' + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user + externalDocs: + description: Find out more about our store + url: 'http://swagger.io' +schemes: + - http +paths: + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + produces: + - application/xml + - application/json + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + collectionFormat: multi + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid status value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: 'Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.' + operationId: findPetsByTags + produces: + - application/xml + - application/json + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + type: array + items: + type: string + collectionFormat: multi + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + type: integer + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + consumes: + - application/x-www-form-urlencoded + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + type: integer + format: int64 + - name: name + in: formData + description: Updated name of the pet + required: false + type: string + - name: status + in: formData + description: Updated status of the pet + required: false + type: string + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + produces: + - application/xml + - application/json + parameters: + - name: api_key + in: header + required: false + type: string + - name: petId + in: path + description: Pet id to delete + required: true + type: integer + format: int64 + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + consumes: + - multipart/form-data + produces: + - application/json + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: file + in: formData + description: file to upload + required: false + type: file + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + produces: + - application/json + parameters: [] + responses: + '200': + description: successful operation + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: order placed for purchasing the pet + required: true + schema: + $ref: '#/definitions/Order' + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Order' + '400': + description: Invalid Order + '/store/order/{orderId}': + get: + tags: + - store + summary: Find purchase order by ID + description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + operationId: getOrderById + produces: + - application/xml + - application/json + parameters: + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + type: integer + maximum: 10 + minimum: 1 + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + operationId: deleteOrder + produces: + - application/xml + - application/json + parameters: + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + type: integer + minimum: 1 + format: int64 + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Created user object + required: true + schema: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: query + description: The user name for login + required: true + type: string + - name: password + in: query + description: The password for login in clear text + required: true + type: string + responses: + '200': + description: successful operation + schema: + type: string + headers: + X-Rate-Limit: + type: integer + format: int32 + description: calls per hour allowed by the user + X-Expires-After: + type: string + format: date-time + description: date in UTC when token expires + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + produces: + - application/xml + - application/json + parameters: [] + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing. ' + required: true + type: string + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: name that need to be updated + required: true + type: string + - in: body + name: body + description: Updated user object + required: true + schema: + $ref: '#/definitions/User' + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found +securityDefinitions: + petstore_auth: + type: oauth2 + authorizationUrl: 'http://petstore.swagger.io/oauth/dialog' + flow: implicit + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header +definitions: + Order: + type: object + description: "this is def" + 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 + 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 + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Category + 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 + category: + $ref: '#/definitions/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/definitions/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string +externalDocs: + description: Find out more about Swagger + url: 'http://swagger.io' From 8292743a0e921d5e23517dbb14c533676733ee9f Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 27 May 2018 12:59:35 +0530 Subject: [PATCH 08/64] changed imports in files referencing samples --- __init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 From cfb27e8987aa4b833aef60a7853a2e319a2c5628 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Fri, 1 Jun 2018 11:42:17 +0530 Subject: [PATCH 09/64] added sample --- hydra_doc_sample.py | 664 ------------------ openapi_sample.yaml => petstore_open_api.yaml | 0 2 files changed, 664 deletions(-) rename openapi_sample.yaml => petstore_open_api.yaml (100%) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 65664d0..a37a474 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,670 +51,6 @@ "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.", "possibleStatus": [], "supportedClass": [ - { - "@id": "vocab:Order", - "@type": "hydra:Class", - "description": "this is def", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:petId", - "readonly": "true", - "required": "false", - "title": "petId", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:quantity", - "readonly": "true", - "required": "false", - "title": "quantity", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:shipDate", - "readonly": "true", - "required": "false", - "title": "shipDate", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:status", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:complete", - "readonly": "true", - "required": "false", - "title": "complete", - "writeonly": "true" - } - ], - "title": "Order" - }, - { - "@id": "vocab:User", - "@type": "hydra:Class", - "description": "User", - "supportedOperation": [ - { - "@type": "http://schema.org/FindAction", - "expects": "vocab:User", - "method": "post", - "possibleStatus": { - "default": { - "description": "successful operation" - } - }, - "returns": "null", - "title": "Create user" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:username", - "readonly": "true", - "required": "false", - "title": "username", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:firstName", - "readonly": "true", - "required": "false", - "title": "firstName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:lastName", - "readonly": "true", - "required": "false", - "title": "lastName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:email", - "readonly": "true", - "required": "false", - "title": "email", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:password", - "readonly": "true", - "required": "false", - "title": "password", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:phone", - "readonly": "true", - "required": "false", - "title": "phone", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:userStatus", - "readonly": "true", - "required": "false", - "title": "userStatus", - "writeonly": "true" - } - ], - "title": "User" - }, - { - "@id": "vocab:Category", - "@type": "hydra:Class", - "description": "Category", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:name", - "readonly": "true", - "required": "false", - "title": "name", - "writeonly": "true" - } - ], - "title": "Category" - }, - { - "@id": "vocab:Tag", - "@type": "hydra:Class", - "description": "Tag", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:name", - "readonly": "true", - "required": "false", - "title": "name", - "writeonly": "true" - } - ], - "title": "Tag" - }, - { - "@id": "vocab:Pet", - "@type": "hydra:Class", - "description": "Pet", - "supportedOperation": [ - { - "@type": "http://schema.org/FindAction", - "expects": "vocab:Pet", - "method": "post", - "possibleStatus": { - "405": { - "description": "Invalid input" - } - }, - "returns": "null", - "title": "Add a new pet to the store" - }, - { - "@type": "http://schema.org/FindAction", - "expects": "vocab:Pet", - "method": "put", - "possibleStatus": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" - } - }, - "returns": "null", - "title": "Update an existing pet" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:category", - "readonly": "true", - "required": "false", - "title": "category", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:name", - "readonly": "true", - "required": "false", - "title": "name", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:photoUrls", - "readonly": "true", - "required": "false", - "title": "photoUrls", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:tags", - "readonly": "true", - "required": "false", - "title": "tags", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:status", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - } - ], - "title": "Pet" - }, - { - "@id": "vocab:ApiResponse", - "@type": "hydra:Class", - "description": "ApiResponse", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:code", - "readonly": "true", - "required": "false", - "title": "code", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:type", - "readonly": "true", - "required": "false", - "title": "type", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:message", - "readonly": "true", - "required": "false", - "title": "message", - "writeonly": "true" - } - ], - "title": "ApiResponse" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", diff --git a/openapi_sample.yaml b/petstore_open_api.yaml similarity index 100% rename from openapi_sample.yaml rename to petstore_open_api.yaml From c911bf31d76453da6874c787abbc2b353c635cc3 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 2 Jun 2018 18:04:25 +0530 Subject: [PATCH 10/64] new working parser --- hydra_doc_sample.py | 750 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 749 insertions(+), 1 deletion(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index a37a474..6ecb3f8 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,6 +51,473 @@ "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.", "possibleStatus": [], "supportedClass": [ + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/AddAction", + "expects": "vocab:Pet", + "method": "PUT", + "possibleStatus": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "returns": "null", + "title": "Update an existing pet" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:category", + "readonly": "true", + "required": "false", + "title": "category", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:photoUrls", + "readonly": "true", + "required": "false", + "title": "photoUrls", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:tags", + "readonly": "true", + "required": "false", + "title": "tags", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + } + ], + "title": "Pet" + }, + { + "@id": "vocab:Order", + "@type": "hydra:Class", + "description": "this is def", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Order", + "method": "POST", + "possibleStatus": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/Order" + } + }, + "400": { + "description": "Invalid Order" + } + }, + "returns": "null", + "title": "Place an order for a pet" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:petId", + "readonly": "true", + "required": "false", + "title": "petId", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:quantity", + "readonly": "true", + "required": "false", + "title": "quantity", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:shipDate", + "readonly": "true", + "required": "false", + "title": "shipDate", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:complete", + "readonly": "true", + "required": "false", + "title": "complete", + "writeonly": "true" + } + ], + "title": "Order" + }, + { + "@id": "vocab:User", + "@type": "hydra:Class", + "description": "User", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:User", + "method": "POST", + "possibleStatus": { + "default": { + "description": "successful operation" + } + }, + "returns": "null", + "title": "Create user" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:username", + "readonly": "true", + "required": "false", + "title": "username", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:firstName", + "readonly": "true", + "required": "false", + "title": "firstName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:lastName", + "readonly": "true", + "required": "false", + "title": "lastName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:email", + "readonly": "true", + "required": "false", + "title": "email", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:password", + "readonly": "true", + "required": "false", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", + "writeonly": "true" + } + ], + "title": "User" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Collection", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "null", + "title": "members", + "writeonly": "false" + } + ], + "title": "Collection" + }, + { + "@id": "http://www.w3.org/ns/hydra/core#Resource", + "@type": "hydra:Class", + "description": "null", + "supportedOperation": [], + "supportedProperty": [], + "title": "Resource" + }, + { + "@id": "vocab:PetCollection", + "@type": "hydra:Class", + "description": "A collection of pet", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The pet", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "PetCollection" + }, + { + "@id": "vocab:OrderCollection", + "@type": "hydra:Class", + "description": "A collection of order", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:order_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Order entities", + "expects": "null", + "method": "GET", + "returns": "vocab:OrderCollection", + "statusCodes": [] + }, + { + "@id": "_:order_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Order entitity", + "expects": "vocab:Order", + "method": "PUT", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "If the Order entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The order", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "OrderCollection" + }, + { + "@id": "vocab:UserCollection", + "@type": "hydra:Class", + "description": "A collection of user", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:user_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all User entities", + "expects": "null", + "method": "GET", + "returns": "vocab:UserCollection", + "statusCodes": [] + }, + { + "@id": "_:user_create", + "@type": "http://schema.org/AddAction", + "description": "Create new User entitity", + "expects": "vocab:User", + "method": "PUT", + "returns": "vocab:User", + "statusCodes": [ + { + "description": "If the User entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The user", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "UserCollection" + }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -66,7 +533,288 @@ "statusCodes": "vocab:EntryPoint" } ], - "supportedProperty": [], + "supportedProperty": [ + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The OrderCollection collection", + "hydra:title": "ordercollection", + "property": { + "@id": "vocab:EntryPoint/OrderCollection", + "@type": "hydra:Link", + "description": "The OrderCollection collection", + "domain": "vocab:EntryPoint", + "label": "OrderCollection", + "range": "vocab:OrderCollection", + "supportedOperation": [ + { + "@id": "_:_:order_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Order entities", + "expects": "null", + "method": "GET", + "returns": "vocab:OrderCollection", + "statusCodes": [] + }, + { + "@id": "_:_:order_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Order entitity", + "expects": "vocab:Order", + "method": "PUT", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "If the Order entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The OrderCollection collection", + "hydra:title": "ordercollection", + "property": { + "@id": "vocab:EntryPoint/OrderCollection", + "@type": "hydra:Link", + "description": "The OrderCollection collection", + "domain": "vocab:EntryPoint", + "label": "OrderCollection", + "range": "vocab:OrderCollection", + "supportedOperation": [ + { + "@id": "_:_:order_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Order entities", + "expects": "null", + "method": "GET", + "returns": "vocab:OrderCollection", + "statusCodes": [] + }, + { + "@id": "_:_:order_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Order entitity", + "expects": "vocab:Order", + "method": "PUT", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "If the Order entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The UserCollection collection", + "hydra:title": "usercollection", + "property": { + "@id": "vocab:EntryPoint/UserCollection", + "@type": "hydra:Link", + "description": "The UserCollection collection", + "domain": "vocab:EntryPoint", + "label": "UserCollection", + "range": "vocab:UserCollection", + "supportedOperation": [ + { + "@id": "_:_:user_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all User entities", + "expects": "null", + "method": "GET", + "returns": "vocab:UserCollection", + "statusCodes": [] + }, + { + "@id": "_:_:user_create", + "@type": "http://schema.org/AddAction", + "description": "Create new User entitity", + "expects": "vocab:User", + "method": "PUT", + "returns": "vocab:User", + "statusCodes": [ + { + "description": "If the User entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + } + ], "title": "EntryPoint" } ], From 21400c981512b6470285044c32a4225914487aa0 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 2 Jun 2018 19:43:02 +0530 Subject: [PATCH 11/64] fixed implementation errors --- hydra_doc_sample.py | 334 +++++++++++++---------------------------- petstore_open_api.yaml | 24 +++ 2 files changed, 127 insertions(+), 231 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 6ecb3f8..ba125b4 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -127,82 +127,6 @@ ], "title": "Pet" }, - { - "@id": "vocab:Order", - "@type": "hydra:Class", - "description": "this is def", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Order", - "method": "POST", - "possibleStatus": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/Order" - } - }, - "400": { - "description": "Invalid Order" - } - }, - "returns": "null", - "title": "Place an order for a pet" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:petId", - "readonly": "true", - "required": "false", - "title": "petId", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:quantity", - "readonly": "true", - "required": "false", - "title": "quantity", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:shipDate", - "readonly": "true", - "required": "false", - "title": "shipDate", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:status", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:complete", - "readonly": "true", - "required": "false", - "title": "complete", - "writeonly": "true" - } - ], - "title": "Order" - }, { "@id": "vocab:User", "@type": "hydra:Class", @@ -364,31 +288,6 @@ "supportedProperty": [], "title": "Resource" }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, { "@id": "vocab:PetCollection", "@type": "hydra:Class", @@ -432,49 +331,6 @@ ], "title": "PetCollection" }, - { - "@id": "vocab:OrderCollection", - "@type": "hydra:Class", - "description": "A collection of order", - "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", - "supportedOperation": [ - { - "@id": "_:order_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", - "expects": "null", - "method": "GET", - "returns": "vocab:OrderCollection", - "statusCodes": [] - }, - { - "@id": "_:order_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", - "method": "PUT", - "returns": "vocab:Order", - "statusCodes": [ - { - "description": "If the Order entity was created successfully.", - "statusCode": 201 - } - ] - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "description": "The order", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "false", - "title": "members", - "writeonly": "false" - } - ], - "title": "OrderCollection" - }, { "@id": "vocab:UserCollection", "@type": "hydra:Class", @@ -534,6 +390,37 @@ } ], "supportedProperty": [ + { + "hydra:description": "The Pet Class", + "hydra:title": "pet", + "property": { + "@id": "vocab:EntryPoint/Pet", + "@type": "hydra:Link", + "description": "Pet", + "domain": "vocab:EntryPoint", + "label": "Pet", + "range": "vocab:Pet", + "supportedOperation": [ + { + "@id": "_:add a new pet to the store", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:Pet", + "label": "Add a new pet to the store", + "method": "POST", + "returns": "null", + "statusCodes": { + "405": { + "description": "Invalid input" + } + } + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, { "hydra:description": "The PetCollection collection", "hydra:title": "petcollection", @@ -575,38 +462,35 @@ "writeonly": "false" }, { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", + "hydra:description": "The Pet Class", + "hydra:title": "pet", "property": { - "@id": "vocab:EntryPoint/PetCollection", + "@id": "vocab:EntryPoint/Pet", "@type": "hydra:Link", - "description": "The PetCollection collection", + "description": "Pet", "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", + "label": "Pet", + "range": "vocab:Pet", "supportedOperation": [ { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", + "@id": "_:update an existing pet", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", + "description": "null", "expects": "vocab:Pet", + "label": "Update an existing pet", "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 + "returns": "null", + "statusCodes": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" } - ] + } } ] }, @@ -655,38 +539,35 @@ "writeonly": "false" }, { - "hydra:description": "The OrderCollection collection", - "hydra:title": "ordercollection", + "hydra:description": "The Pet Class", + "hydra:title": "pet", "property": { - "@id": "vocab:EntryPoint/OrderCollection", + "@id": "vocab:EntryPoint/Pet", "@type": "hydra:Link", - "description": "The OrderCollection collection", + "description": "Pet", "domain": "vocab:EntryPoint", - "label": "OrderCollection", - "range": "vocab:OrderCollection", + "label": "Pet", + "range": "vocab:Pet", "supportedOperation": [ { - "@id": "_:_:order_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", - "expects": "null", - "method": "GET", - "returns": "vocab:OrderCollection", - "statusCodes": [] - }, - { - "@id": "_:_:order_create", + "@id": "_:update an existing pet", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "null", + "expects": "vocab:Pet", + "label": "Update an existing pet", "method": "PUT", - "returns": "vocab:Order", - "statusCodes": [ - { - "description": "If the Order entity was created successfully.", - "statusCode": 201 + "returns": "null", + "statusCodes": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" } - ] + } } ] }, @@ -695,38 +576,29 @@ "writeonly": "false" }, { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", + "hydra:description": "The User Class", + "hydra:title": "user", "property": { - "@id": "vocab:EntryPoint/PetCollection", + "@id": "vocab:EntryPoint/User", "@type": "hydra:Link", - "description": "The PetCollection collection", + "description": "User", "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", + "label": "User", + "range": "vocab:User", "supportedOperation": [ { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 + "@id": "_:create user", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:User", + "label": "Create user", + "method": "POST", + "returns": "null", + "statusCodes": { + "default": { + "description": "successful operation" } - ] + } } ] }, @@ -735,35 +607,35 @@ "writeonly": "false" }, { - "hydra:description": "The OrderCollection collection", - "hydra:title": "ordercollection", + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint/OrderCollection", + "@id": "vocab:EntryPoint/PetCollection", "@type": "hydra:Link", - "description": "The OrderCollection collection", + "description": "The PetCollection collection", "domain": "vocab:EntryPoint", - "label": "OrderCollection", - "range": "vocab:OrderCollection", + "label": "PetCollection", + "range": "vocab:PetCollection", "supportedOperation": [ { - "@id": "_:_:order_collection_retrieve", + "@id": "_:_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:_:order_create", + "@id": "_:_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] diff --git a/petstore_open_api.yaml b/petstore_open_api.yaml index e426e6b..d779357 100644 --- a/petstore_open_api.yaml +++ b/petstore_open_api.yaml @@ -84,6 +84,30 @@ paths: - petstore_auth: - 'write:pets' - 'read:pets' + get: + summary: get all pets + description: get all pets + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + collectionFormat: multi + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' /pet/findByStatus: get: tags: From f1aa4a1db60e7892f1cc75150dfee96e7e6ef695 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 3 Jun 2018 18:16:11 +0530 Subject: [PATCH 12/64] fixed bugs --- hydra_doc_sample.py | 196 +++----------------------------------------- 1 file changed, 12 insertions(+), 184 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index ba125b4..c72590d 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -56,6 +56,18 @@ "@type": "hydra:Class", "description": "Pet", "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Pet", + "method": "POST", + "possibleStatus": { + "405": { + "description": "Invalid input" + } + }, + "returns": "null", + "title": "Add a new pet to the store" + }, { "@type": "http://schema.org/AddAction", "expects": "vocab:Pet", @@ -238,56 +250,6 @@ "supportedProperty": [], "title": "Resource" }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Collection", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "null", - "title": "members", - "writeonly": "false" - } - ], - "title": "Collection" - }, - { - "@id": "http://www.w3.org/ns/hydra/core#Resource", - "@type": "hydra:Class", - "description": "null", - "supportedOperation": [], - "supportedProperty": [], - "title": "Resource" - }, { "@id": "vocab:PetCollection", "@type": "hydra:Class", @@ -414,141 +376,7 @@ "description": "Invalid input" } } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", - "property": { - "@id": "vocab:EntryPoint/PetCollection", - "@type": "hydra:Link", - "description": "The PetCollection collection", - "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", - "supportedOperation": [ - { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The Pet Class", - "hydra:title": "pet", - "property": { - "@id": "vocab:EntryPoint/Pet", - "@type": "hydra:Link", - "description": "Pet", - "domain": "vocab:EntryPoint", - "label": "Pet", - "range": "vocab:Pet", - "supportedOperation": [ - { - "@id": "_:update an existing pet", - "@type": "http://schema.org/AddAction", - "description": "null", - "expects": "vocab:Pet", - "label": "Update an existing pet", - "method": "PUT", - "returns": "null", - "statusCodes": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" - } - } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", - "property": { - "@id": "vocab:EntryPoint/PetCollection", - "@type": "hydra:Link", - "description": "The PetCollection collection", - "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", - "supportedOperation": [ - { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The Pet Class", - "hydra:title": "pet", - "property": { - "@id": "vocab:EntryPoint/Pet", - "@type": "hydra:Link", - "description": "Pet", - "domain": "vocab:EntryPoint", - "label": "Pet", - "range": "vocab:Pet", - "supportedOperation": [ { "@id": "_:update an existing pet", "@type": "http://schema.org/AddAction", From 33901707bbc3982dcf676ad26e2072ceeac73947 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 3 Jun 2018 18:35:42 +0530 Subject: [PATCH 13/64] fixed architecture --- hydra_doc_sample.py | 425 +------------------------------------------- 1 file changed, 1 insertion(+), 424 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index c72590d..9cf3164 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,180 +51,6 @@ "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.", "possibleStatus": [], "supportedClass": [ - { - "@id": "vocab:Pet", - "@type": "hydra:Class", - "description": "Pet", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", - "method": "POST", - "possibleStatus": { - "405": { - "description": "Invalid input" - } - }, - "returns": "null", - "title": "Add a new pet to the store" - }, - { - "@type": "http://schema.org/AddAction", - "expects": "vocab:Pet", - "method": "PUT", - "possibleStatus": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" - } - }, - "returns": "null", - "title": "Update an existing pet" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:category", - "readonly": "true", - "required": "false", - "title": "category", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:name", - "readonly": "true", - "required": "false", - "title": "name", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:photoUrls", - "readonly": "true", - "required": "false", - "title": "photoUrls", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:tags", - "readonly": "true", - "required": "false", - "title": "tags", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:status", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - } - ], - "title": "Pet" - }, - { - "@id": "vocab:User", - "@type": "hydra:Class", - "description": "User", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", - "method": "POST", - "possibleStatus": { - "default": { - "description": "successful operation" - } - }, - "returns": "null", - "title": "Create user" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:username", - "readonly": "true", - "required": "false", - "title": "username", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:firstName", - "readonly": "true", - "required": "false", - "title": "firstName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:lastName", - "readonly": "true", - "required": "false", - "title": "lastName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:email", - "readonly": "true", - "required": "false", - "title": "email", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:password", - "readonly": "true", - "required": "false", - "title": "password", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:phone", - "readonly": "true", - "required": "false", - "title": "phone", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:userStatus", - "readonly": "true", - "required": "false", - "title": "userStatus", - "writeonly": "true" - } - ], - "title": "User" - }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", "@type": "hydra:Class", @@ -250,92 +76,6 @@ "supportedProperty": [], "title": "Resource" }, - { - "@id": "vocab:PetCollection", - "@type": "hydra:Class", - "description": "A collection of pet", - "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", - "supportedOperation": [ - { - "@id": "_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "description": "The pet", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "false", - "title": "members", - "writeonly": "false" - } - ], - "title": "PetCollection" - }, - { - "@id": "vocab:UserCollection", - "@type": "hydra:Class", - "description": "A collection of user", - "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", - "supportedOperation": [ - { - "@id": "_:user_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", - "expects": "null", - "method": "GET", - "returns": "vocab:UserCollection", - "statusCodes": [] - }, - { - "@id": "_:user_create", - "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", - "method": "PUT", - "returns": "vocab:User", - "statusCodes": [ - { - "description": "If the User entity was created successfully.", - "statusCode": 201 - } - ] - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "description": "The user", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "false", - "title": "members", - "writeonly": "false" - } - ], - "title": "UserCollection" - }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -351,170 +91,7 @@ "statusCodes": "vocab:EntryPoint" } ], - "supportedProperty": [ - { - "hydra:description": "The Pet Class", - "hydra:title": "pet", - "property": { - "@id": "vocab:EntryPoint/Pet", - "@type": "hydra:Link", - "description": "Pet", - "domain": "vocab:EntryPoint", - "label": "Pet", - "range": "vocab:Pet", - "supportedOperation": [ - { - "@id": "_:add a new pet to the store", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:Pet", - "label": "Add a new pet to the store", - "method": "POST", - "returns": "null", - "statusCodes": { - "405": { - "description": "Invalid input" - } - } - }, - { - "@id": "_:update an existing pet", - "@type": "http://schema.org/AddAction", - "description": "null", - "expects": "vocab:Pet", - "label": "Update an existing pet", - "method": "PUT", - "returns": "null", - "statusCodes": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" - } - } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The User Class", - "hydra:title": "user", - "property": { - "@id": "vocab:EntryPoint/User", - "@type": "hydra:Link", - "description": "User", - "domain": "vocab:EntryPoint", - "label": "User", - "range": "vocab:User", - "supportedOperation": [ - { - "@id": "_:create user", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:User", - "label": "Create user", - "method": "POST", - "returns": "null", - "statusCodes": { - "default": { - "description": "successful operation" - } - } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", - "property": { - "@id": "vocab:EntryPoint/PetCollection", - "@type": "hydra:Link", - "description": "The PetCollection collection", - "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", - "supportedOperation": [ - { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The UserCollection collection", - "hydra:title": "usercollection", - "property": { - "@id": "vocab:EntryPoint/UserCollection", - "@type": "hydra:Link", - "description": "The UserCollection collection", - "domain": "vocab:EntryPoint", - "label": "UserCollection", - "range": "vocab:UserCollection", - "supportedOperation": [ - { - "@id": "_:_:user_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", - "expects": "null", - "method": "GET", - "returns": "vocab:UserCollection", - "statusCodes": [] - }, - { - "@id": "_:_:user_create", - "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", - "method": "PUT", - "returns": "vocab:User", - "statusCodes": [ - { - "description": "If the User entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - } - ], + "supportedProperty": [], "title": "EntryPoint" } ], From c61f5cea19486a9886276682ad1946fa5ee7a310 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Mon, 4 Jun 2018 13:01:37 +0530 Subject: [PATCH 14/64] new sample --- hydra_doc_sample.py | 380 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 379 insertions(+), 1 deletion(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 9cf3164..f0ac1c6 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,6 +51,198 @@ "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.", "possibleStatus": [], "supportedClass": [ + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Pet", + "method": "POST", + "possibleStatus": { + "405": { + "description": "Invalid input" + } + }, + "returns": "null", + "title": "Add a new pet to the store" + }, + { + "@type": "http://schema.org/AddAction", + "expects": "vocab:Pet", + "method": "PUT", + "possibleStatus": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "returns": "null", + "title": "Update an existing pet" + }, + { + "@type": "http://schema.org/FindAction", + "expects": "null", + "method": "GET", + "possibleStatus": { + "200": { + "description": "successful operation", + "schema": { + "items": { + "$ref": "#/definitions/Pet" + }, + "type": "array" + } + } + }, + "returns": "null", + "title": "get all pets" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:category", + "readonly": "true", + "required": "false", + "title": "category", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:photoUrls", + "readonly": "true", + "required": "false", + "title": "photoUrls", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:tags", + "readonly": "true", + "required": "false", + "title": "tags", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + } + ], + "title": "Pet" + }, + { + "@id": "vocab:User", + "@type": "hydra:Class", + "description": "User", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:User", + "method": "POST", + "possibleStatus": { + "default": { + "description": "successful operation" + } + }, + "returns": "null", + "title": "Create user" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:username", + "readonly": "true", + "required": "false", + "title": "username", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:firstName", + "readonly": "true", + "required": "false", + "title": "firstName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:lastName", + "readonly": "true", + "required": "false", + "title": "lastName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:email", + "readonly": "true", + "required": "false", + "title": "email", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:password", + "readonly": "true", + "required": "false", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", + "writeonly": "true" + } + ], + "title": "User" + }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", "@type": "hydra:Class", @@ -76,6 +268,49 @@ "supportedProperty": [], "title": "Resource" }, + { + "@id": "vocab:PetCollection", + "@type": "hydra:Class", + "description": "A collection of pet", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The pet", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "PetCollection" + }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -91,7 +326,150 @@ "statusCodes": "vocab:EntryPoint" } ], - "supportedProperty": [], + "supportedProperty": [ + { + "hydra:description": "The Pet Class", + "hydra:title": "pet", + "property": { + "@id": "vocab:EntryPoint/Pet", + "@type": "hydra:Link", + "description": "Pet", + "domain": "vocab:EntryPoint", + "label": "Pet", + "range": "vocab:Pet", + "supportedOperation": [ + { + "@id": "_:add a new pet to the store", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:Pet", + "label": "Add a new pet to the store", + "method": "POST", + "returns": "null", + "statusCodes": { + "405": { + "description": "Invalid input" + } + } + }, + { + "@id": "_:update an existing pet", + "@type": "http://schema.org/AddAction", + "description": "null", + "expects": "vocab:Pet", + "label": "Update an existing pet", + "method": "PUT", + "returns": "null", + "statusCodes": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + } + }, + { + "@id": "_:get all pets", + "@type": "http://schema.org/FindAction", + "description": "null", + "expects": "null", + "label": "get all pets", + "method": "GET", + "returns": "null", + "statusCodes": { + "200": { + "description": "successful operation", + "schema": { + "items": { + "$ref": "#/definitions/Pet" + }, + "type": "array" + } + } + } + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The User Class", + "hydra:title": "user", + "property": { + "@id": "vocab:EntryPoint/User", + "@type": "hydra:Link", + "description": "User", + "domain": "vocab:EntryPoint", + "label": "User", + "range": "vocab:User", + "supportedOperation": [ + { + "@id": "_:create user", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:User", + "label": "Create user", + "method": "POST", + "returns": "null", + "statusCodes": { + "default": { + "description": "successful operation" + } + } + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + } + ], "title": "EntryPoint" } ], From 77e3c90362ab38bf522c2c87905d77dec65e1cf8 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Mon, 4 Jun 2018 14:25:41 +0530 Subject: [PATCH 15/64] required functionality added --- hydra_doc_sample.py | 121 +------------------------------------------- 1 file changed, 2 insertions(+), 119 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index f0ac1c6..4c2165f 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -126,7 +126,7 @@ "@type": "SupportedProperty", "property": "vocab:name", "readonly": "true", - "required": "false", + "required": "true", "title": "name", "writeonly": "true" }, @@ -134,7 +134,7 @@ "@type": "SupportedProperty", "property": "vocab:photoUrls", "readonly": "true", - "required": "false", + "required": "true", "title": "photoUrls", "writeonly": "true" }, @@ -157,92 +157,6 @@ ], "title": "Pet" }, - { - "@id": "vocab:User", - "@type": "hydra:Class", - "description": "User", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", - "method": "POST", - "possibleStatus": { - "default": { - "description": "successful operation" - } - }, - "returns": "null", - "title": "Create user" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:username", - "readonly": "true", - "required": "false", - "title": "username", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:firstName", - "readonly": "true", - "required": "false", - "title": "firstName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:lastName", - "readonly": "true", - "required": "false", - "title": "lastName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:email", - "readonly": "true", - "required": "false", - "title": "email", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:password", - "readonly": "true", - "required": "false", - "title": "password", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:phone", - "readonly": "true", - "required": "false", - "title": "phone", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:userStatus", - "readonly": "true", - "required": "false", - "title": "userStatus", - "writeonly": "true" - } - ], - "title": "User" - }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", "@type": "hydra:Class", @@ -398,37 +312,6 @@ "required": "null", "writeonly": "false" }, - { - "hydra:description": "The User Class", - "hydra:title": "user", - "property": { - "@id": "vocab:EntryPoint/User", - "@type": "hydra:Link", - "description": "User", - "domain": "vocab:EntryPoint", - "label": "User", - "range": "vocab:User", - "supportedOperation": [ - { - "@id": "_:create user", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:User", - "label": "Create user", - "method": "POST", - "returns": "null", - "statusCodes": { - "default": { - "description": "successful operation" - } - } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, { "hydra:description": "The PetCollection collection", "hydra:title": "petcollection", From 9d861c508bf1467019e9a1ee10ca5184460a6c7f Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Mon, 4 Jun 2018 22:40:03 +0530 Subject: [PATCH 16/64] fixed bug --- hydra_doc_sample.py | 117 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 4c2165f..1cd704b 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -157,6 +157,92 @@ ], "title": "Pet" }, + { + "@id": "vocab:User", + "@type": "hydra:Class", + "description": "User", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:User", + "method": "POST", + "possibleStatus": { + "default": { + "description": "successful operation" + } + }, + "returns": "null", + "title": "Create user" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:username", + "readonly": "true", + "required": "false", + "title": "username", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:firstName", + "readonly": "true", + "required": "false", + "title": "firstName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:lastName", + "readonly": "true", + "required": "false", + "title": "lastName", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:email", + "readonly": "true", + "required": "false", + "title": "email", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:password", + "readonly": "true", + "required": "false", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", + "writeonly": "true" + } + ], + "title": "User" + }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", "@type": "hydra:Class", @@ -312,6 +398,37 @@ "required": "null", "writeonly": "false" }, + { + "hydra:description": "The User Class", + "hydra:title": "user", + "property": { + "@id": "vocab:EntryPoint/User", + "@type": "hydra:Link", + "description": "User", + "domain": "vocab:EntryPoint", + "label": "User", + "range": "vocab:User", + "supportedOperation": [ + { + "@id": "_:create user", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:User", + "label": "Create user", + "method": "POST", + "returns": "null", + "statusCodes": { + "default": { + "description": "successful operation" + } + } + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, { "hydra:description": "The PetCollection collection", "hydra:title": "petcollection", From dfd1420310726d04e6a950bee5fb57d3cac0e98e Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Tue, 5 Jun 2018 16:41:25 +0530 Subject: [PATCH 17/64] added protocol to id --- hydra_doc_sample.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 1cd704b..7846d10 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -43,10 +43,10 @@ "supportedOperation": "hydra:supportedOperation", "supportedProperty": "hydra:supportedProperty", "title": "hydra:title", - "vocab": "petstore.swagger.io/v2/vocab#", + "vocab": "http://petstore.swagger.io/v2/vocab#", "writeonly": "hydra:writeonly" }, - "@id": "petstore.swagger.io/v2/vocab", + "@id": "http://petstore.swagger.io/v2/vocab", "@type": "ApiDocumentation", "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.", "possibleStatus": [], From 9d9b17198270a7a0a35a88a62b88857d4c13349b Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 6 Jun 2018 16:43:33 +0530 Subject: [PATCH 18/64] parsed responses --- hydra_doc_sample.py | 157 +++++++++----------------------------------- 1 file changed, 31 insertions(+), 126 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 7846d10..228fce9 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -60,11 +60,12 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:Pet", "method": "POST", - "possibleStatus": { - "405": { - "description": "Invalid input" + "possibleStatus": [ + { + "description": "dummyClass updated", + "statusCode": 200 } - }, + ], "returns": "null", "title": "Add a new pet to the store" }, @@ -72,17 +73,12 @@ "@type": "http://schema.org/AddAction", "expects": "vocab:Pet", "method": "PUT", - "possibleStatus": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" + "possibleStatus": [ + { + "description": "dummyClass updated", + "statusCode": 200 } - }, + ], "returns": "null", "title": "Update an existing pet" }, @@ -94,14 +90,11 @@ "200": { "description": "successful operation", "schema": { - "items": { - "$ref": "#/definitions/Pet" - }, - "type": "array" + "$ref": "#/definitions/Pet" } } }, - "returns": "null", + "returns": "vocab:Pet", "title": "get all pets" } ], @@ -166,11 +159,12 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:User", "method": "POST", - "possibleStatus": { - "default": { - "description": "successful operation" + "possibleStatus": [ + { + "description": "dummyClass updated", + "statusCode": 200 } - }, + ], "returns": "null", "title": "Create user" } @@ -268,49 +262,6 @@ "supportedProperty": [], "title": "Resource" }, - { - "@id": "vocab:PetCollection", - "@type": "hydra:Class", - "description": "A collection of pet", - "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", - "supportedOperation": [ - { - "@id": "_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "description": "The pet", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "false", - "title": "members", - "writeonly": "false" - } - ], - "title": "PetCollection" - }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -346,11 +297,12 @@ "label": "Add a new pet to the store", "method": "POST", "returns": "null", - "statusCodes": { - "405": { - "description": "Invalid input" + "statusCodes": [ + { + "description": "dummyClass updated", + "statusCode": 200 } - } + ] }, { "@id": "_:update an existing pet", @@ -360,17 +312,12 @@ "label": "Update an existing pet", "method": "PUT", "returns": "null", - "statusCodes": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" + "statusCodes": [ + { + "description": "dummyClass updated", + "statusCode": 200 } - } + ] }, { "@id": "_:get all pets", @@ -379,15 +326,12 @@ "expects": "null", "label": "get all pets", "method": "GET", - "returns": "null", + "returns": "vocab:Pet", "statusCodes": { "200": { "description": "successful operation", "schema": { - "items": { - "$ref": "#/definitions/Pet" - }, - "type": "array" + "$ref": "#/definitions/Pet" } } } @@ -417,49 +361,10 @@ "label": "Create user", "method": "POST", "returns": "null", - "statusCodes": { - "default": { - "description": "successful operation" - } - } - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", - "property": { - "@id": "vocab:EntryPoint/PetCollection", - "@type": "hydra:Link", - "description": "The PetCollection collection", - "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", - "supportedOperation": [ - { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 + "description": "dummyClass updated", + "statusCode": 200 } ] } From 4f60f2d434b3480a115ca188f12543bb3b0ce612 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 6 Jun 2018 17:24:54 +0530 Subject: [PATCH 19/64] fixed status bug --- hydra_doc_sample.py | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 228fce9..dbdc721 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -60,12 +60,11 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:Pet", "method": "POST", - "possibleStatus": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "possibleStatus": { + "405": { + "description": "Invalid input" } - ], + }, "returns": "null", "title": "Add a new pet to the store" }, @@ -73,12 +72,17 @@ "@type": "http://schema.org/AddAction", "expects": "vocab:Pet", "method": "PUT", - "possibleStatus": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "possibleStatus": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" } - ], + }, "returns": "null", "title": "Update an existing pet" }, @@ -159,12 +163,11 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:User", "method": "POST", - "possibleStatus": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "possibleStatus": { + "default": { + "description": "successful operation" } - ], + }, "returns": "null", "title": "Create user" } @@ -297,12 +300,11 @@ "label": "Add a new pet to the store", "method": "POST", "returns": "null", - "statusCodes": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "statusCodes": { + "405": { + "description": "Invalid input" } - ] + } }, { "@id": "_:update an existing pet", @@ -312,12 +314,17 @@ "label": "Update an existing pet", "method": "PUT", "returns": "null", - "statusCodes": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "statusCodes": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" } - ] + } }, { "@id": "_:get all pets", @@ -361,12 +368,11 @@ "label": "Create user", "method": "POST", "returns": "null", - "statusCodes": [ - { - "description": "dummyClass updated", - "statusCode": 200 + "statusCodes": { + "default": { + "description": "successful operation" } - ] + } } ] }, From b488cf8bd7eacc9c16e34c2002e2d7a118d53a6e Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 6 Jun 2018 17:46:44 +0530 Subject: [PATCH 20/64] removed schema from responses --- hydra_doc_sample.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index dbdc721..380041e 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -92,10 +92,7 @@ "method": "GET", "possibleStatus": { "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/Pet" - } + "description": "successful operation" } }, "returns": "vocab:Pet", @@ -336,10 +333,7 @@ "returns": "vocab:Pet", "statusCodes": { "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/Pet" - } + "description": "successful operation" } } } From 58988358f16ec849c8974e4a4e8e1b0963c7f173 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 9 Jun 2018 12:52:22 +0530 Subject: [PATCH 21/64] refactoed status represntation --- hydra_doc_sample.py | 167 ++++++++++++++++++++++++++++++++------------ 1 file changed, 123 insertions(+), 44 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 380041e..a8ac427 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -60,11 +60,12 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:Pet", "method": "POST", - "possibleStatus": { - "405": { - "description": "Invalid input" + "possibleStatus": [ + { + "description": "Invalid input", + "statusCode": "405" } - }, + ], "returns": "null", "title": "Add a new pet to the store" }, @@ -72,17 +73,12 @@ "@type": "http://schema.org/AddAction", "expects": "vocab:Pet", "method": "PUT", - "possibleStatus": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" + "possibleStatus": [ + { + "description": "Invalid ID supplied", + "statusCode": "400" } - }, + ], "returns": "null", "title": "Update an existing pet" }, @@ -90,11 +86,12 @@ "@type": "http://schema.org/FindAction", "expects": "null", "method": "GET", - "possibleStatus": { - "200": { - "description": "successful operation" + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": "200" } - }, + ], "returns": "vocab:Pet", "title": "get all pets" } @@ -160,11 +157,12 @@ "@type": "http://schema.org/UpdateAction", "expects": "vocab:User", "method": "POST", - "possibleStatus": { - "default": { - "description": "successful operation" + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": "default" } - }, + ], "returns": "null", "title": "Create user" } @@ -262,6 +260,49 @@ "supportedProperty": [], "title": "Resource" }, + { + "@id": "vocab:PetCollection", + "@type": "hydra:Class", + "description": "A collection of pet", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The pet", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "PetCollection" + }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -297,11 +338,12 @@ "label": "Add a new pet to the store", "method": "POST", "returns": "null", - "statusCodes": { - "405": { - "description": "Invalid input" + "statusCodes": [ + { + "description": "Invalid input", + "statusCode": "405" } - } + ] }, { "@id": "_:update an existing pet", @@ -311,17 +353,12 @@ "label": "Update an existing pet", "method": "PUT", "returns": "null", - "statusCodes": { - "400": { - "description": "Invalid ID supplied" - }, - "404": { - "description": "Pet not found" - }, - "405": { - "description": "Validation exception" + "statusCodes": [ + { + "description": "Invalid ID supplied", + "statusCode": "400" } - } + ] }, { "@id": "_:get all pets", @@ -331,11 +368,12 @@ "label": "get all pets", "method": "GET", "returns": "vocab:Pet", - "statusCodes": { - "200": { - "description": "successful operation" + "statusCodes": [ + { + "description": "successful operation", + "statusCode": "200" } - } + ] } ] }, @@ -362,11 +400,52 @@ "label": "Create user", "method": "POST", "returns": "null", - "statusCodes": { - "default": { - "description": "successful operation" + "statusCodes": [ + { + "description": "successful operation", + "statusCode": "default" + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", + "property": { + "@id": "vocab:EntryPoint/PetCollection", + "@type": "hydra:Link", + "description": "The PetCollection collection", + "domain": "vocab:EntryPoint", + "label": "PetCollection", + "range": "vocab:PetCollection", + "supportedOperation": [ + { + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", + "method": "PUT", + "returns": "vocab:Pet", + "statusCodes": [ + { + "description": "If the Pet entity was created successfully.", + "statusCode": 201 } - } + ] } ] }, From f94244d8a8f64f508c658acc7fbec5ef6bc98e0c Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 10 Jun 2018 01:20:51 +0530 Subject: [PATCH 22/64] added test --- petstore_open_api.yaml => petstore_openapi.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename petstore_open_api.yaml => petstore_openapi.yaml (100%) diff --git a/petstore_open_api.yaml b/petstore_openapi.yaml similarity index 100% rename from petstore_open_api.yaml rename to petstore_openapi.yaml From ca12a45c1668fe76232209044712b6829737c803 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 10 Jun 2018 01:40:32 +0530 Subject: [PATCH 23/64] Added test file --- test_parser.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test_parser.py diff --git a/test_parser.py b/test_parser.py new file mode 100644 index 0000000..96c254f --- /dev/null +++ b/test_parser.py @@ -0,0 +1,30 @@ +import unittest +from hydrus.parser import openapi_parser as parser +import yaml + + +def import_doc(): + print("Importing Open Api Documentation ..") + with open("../samples/petstore_openapi.yaml", 'r') as stream: + try: + return yaml.load(stream) + except yaml.YAMLError as exc: + print(exc) + + +class TestParser(unittest.TestCase): + @classmethod + def setUpClass(cls): + pass + + @classmethod + def tearDownClass(cls): + pass + + def test_check_if_collection(self): + pass + + +if __name__ == '__main__': + print("Starting tests ..") + unittest.main() \ No newline at end of file From fb7ac5abde2c98916215c09ca5aecd196b65c3ed Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Sun, 17 Jun 2018 17:12:12 +0530 Subject: [PATCH 24/64] Tests fixed, PEP8 fixes --- petstore_openapi.yaml | 726 +++++++++++++++++++++--------------------- 1 file changed, 363 insertions(+), 363 deletions(-) diff --git a/petstore_openapi.yaml b/petstore_openapi.yaml index d779357..7748094 100644 --- a/petstore_openapi.yaml +++ b/petstore_openapi.yaml @@ -1,29 +1,29 @@ -swagger: '2.0' +swagger: '2.0' info: - 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.' - version: 1.0.0 - title: Swagger Petstore - termsOfService: 'http://swagger.io/terms/' + 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.' + version: 1.0.0 + title: Swagger Petstore + termsOfService: 'http://swagger.io/terms/' contact: - email: apiteam@swagger.io + email: apiteam@swagger.io license: - name: Apache 2.0 - url: 'http://www.apache.org/licenses/LICENSE-2.0.html' -host: petstore.swagger.io -basePath: /v2 + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' +host: petstore.swagger.io +basePath: /v2 tags: - - name: pet - description: Everything about your Pets + - name: pet + description: Everything about your Pets externalDocs: - description: Find out more - url: 'http://swagger.io' - - name: store - description: Access to Petstore orders - - name: user - description: Operations about user + description: Find out more + url: 'http://swagger.io' + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user externalDocs: - description: Find out more about our store - url: 'http://swagger.io' + description: Find out more about our store + url: 'http://swagger.io' schemes: - http paths: @@ -31,9 +31,9 @@ paths: post: tags: - pet - summary: Add a new pet to the store - description: '' - operationId: addPet + summary: Add a new pet to the store + description: '' + operationId: addPet consumes: - application/json - application/xml @@ -41,15 +41,15 @@ paths: - application/xml - application/json parameters: - - in: body - name: body - description: Pet object that needs to be added to the store - required: true + - in: body + name: body + description: Pet object that needs to be added to the store + required: true schema: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' responses: '405': - description: Invalid input + description: Invalid input security: - petstore_auth: - 'write:pets' @@ -57,9 +57,9 @@ paths: put: tags: - pet - summary: Update an existing pet - description: '' - operationId: updatePet + summary: Update an existing pet + description: '' + operationId: updatePet consumes: - application/json - application/xml @@ -67,80 +67,80 @@ paths: - application/xml - application/json parameters: - - in: body - name: body - description: Pet object that needs to be added to the store - required: true + - in: body + name: body + description: Pet object that needs to be added to the store + required: true schema: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' responses: '400': - description: Invalid ID supplied + description: Invalid ID supplied '404': - description: Pet not found + description: Pet not found '405': - description: Validation exception + description: Validation exception security: - petstore_auth: - 'write:pets' - 'read:pets' get: - summary: get all pets - description: get all pets + summary: get all pets + description: get all pets parameters: - - name: status - in: query - description: Status values that need to be considered for filter - required: true - type: array + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array items: - type: string + type: string enum: - available - pending - sold - default: available - collectionFormat: multi + default: available + collectionFormat: multi responses: '200': - description: successful operation + description: successful operation schema: - type: array + type: array items: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' /pet/findByStatus: get: tags: - pet - summary: Finds Pets by status - description: Multiple status values can be provided with comma separated strings - operationId: findPetsByStatus + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus produces: - application/xml - application/json parameters: - - name: status - in: query - description: Status values that need to be considered for filter - required: true - type: array + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array items: - type: string + type: string enum: - available - pending - sold - default: available - collectionFormat: multi + default: available + collectionFormat: multi responses: '200': - description: successful operation + description: successful operation schema: - type: array + type: array items: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' '400': - description: Invalid status value + description: Invalid status value security: - petstore_auth: - 'write:pets' @@ -149,94 +149,94 @@ paths: get: tags: - pet - summary: Finds Pets by tags - description: 'Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.' - operationId: findPetsByTags + summary: Finds Pets by tags + description: 'Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.' + operationId: findPetsByTags produces: - application/xml - application/json parameters: - - name: tags - in: query - description: Tags to filter by - required: true - type: array + - name: tags + in: query + description: Tags to filter by + required: true + type: array items: - type: string - collectionFormat: multi + type: string + collectionFormat: multi responses: '200': - description: successful operation + description: successful operation schema: - type: array + type: array items: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' '400': - description: Invalid tag value + description: Invalid tag value security: - petstore_auth: - 'write:pets' - 'read:pets' - deprecated: true + deprecated: true '/pet/{petId}': get: tags: - pet - summary: Find pet by ID - description: Returns a single pet - operationId: getPetById + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById produces: - application/xml - application/json parameters: - - name: petId - in: path - description: ID of pet to return - required: true - type: integer - format: int64 + - name: petId + in: path + description: ID of pet to return + required: true + type: integer + format: int64 responses: '200': - description: successful operation + description: successful operation schema: - $ref: '#/definitions/Pet' + $ref: '#/definitions/Pet' '400': - description: Invalid ID supplied + description: Invalid ID supplied '404': - description: Pet not found + description: Pet not found security: - - api_key: [] + - api_key: [] post: tags: - pet - summary: Updates a pet in the store with form data - description: '' - operationId: updatePetWithForm + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm consumes: - application/x-www-form-urlencoded produces: - application/xml - application/json parameters: - - name: petId - in: path - description: ID of pet that needs to be updated - required: true - type: integer - format: int64 - - name: name - in: formData - description: Updated name of the pet - required: false - type: string - - name: status - in: formData - description: Updated status of the pet - required: false - type: string + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + type: integer + format: int64 + - name: name + in: formData + description: Updated name of the pet + required: false + type: string + - name: status + in: formData + description: Updated status of the pet + required: false + type: string responses: '405': - description: Invalid input + description: Invalid input security: - petstore_auth: - 'write:pets' @@ -244,28 +244,28 @@ paths: delete: tags: - pet - summary: Deletes a pet - description: '' - operationId: deletePet + summary: Deletes a pet + description: '' + operationId: deletePet produces: - application/xml - application/json parameters: - - name: api_key - in: header - required: false - type: string - - name: petId - in: path - description: Pet id to delete - required: true - type: integer - format: int64 + - name: api_key + in: header + required: false + type: string + - name: petId + in: path + description: Pet id to delete + required: true + type: integer + format: int64 responses: '400': - description: Invalid ID supplied + description: Invalid ID supplied '404': - description: Pet not found + description: Pet not found security: - petstore_auth: - 'write:pets' @@ -274,35 +274,35 @@ paths: post: tags: - pet - summary: uploads an image - description: '' - operationId: uploadFile + summary: uploads an image + description: '' + operationId: uploadFile consumes: - multipart/form-data produces: - application/json parameters: - - name: petId - in: path - description: ID of pet to update - required: true - type: integer - format: int64 - - name: additionalMetadata - in: formData - description: Additional data to pass to server - required: false - type: string - - name: file - in: formData - description: file to upload - required: false - type: file + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: file + in: formData + description: file to upload + required: false + type: file responses: '200': - description: successful operation + description: successful operation schema: - $ref: '#/definitions/ApiResponse' + $ref: '#/definitions/ApiResponse' security: - petstore_auth: - 'write:pets' @@ -311,414 +311,414 @@ paths: get: tags: - store - summary: Returns pet inventories by status - description: Returns a map of status codes to quantities - operationId: getInventory + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory produces: - application/json - parameters: [] + parameters: [] responses: '200': - description: successful operation + description: successful operation schema: - type: object + type: object additionalProperties: - type: integer - format: int32 + type: integer + format: int32 security: - - api_key: [] + - api_key: [] /store/order: post: tags: - store - summary: Place an order for a pet - description: '' - operationId: placeOrder + summary: Place an order for a pet + description: '' + operationId: placeOrder produces: - application/xml - application/json parameters: - - in: body - name: body - description: order placed for purchasing the pet - required: true + - in: body + name: body + description: order placed for purchasing the pet + required: true schema: - $ref: '#/definitions/Order' + $ref: '#/definitions/Order' responses: '200': - description: successful operation + description: successful operation schema: - $ref: '#/definitions/Order' + $ref: '#/definitions/Order' '400': - description: Invalid Order + description: Invalid Order '/store/order/{orderId}': get: tags: - store - summary: Find purchase order by ID - description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions - operationId: getOrderById + summary: Find purchase order by ID + description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + operationId: getOrderById produces: - application/xml - application/json parameters: - - name: orderId - in: path - description: ID of pet that needs to be fetched - required: true - type: integer - maximum: 10 - minimum: 1 - format: int64 + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + type: integer + maximum: 10 + minimum: 1 + format: int64 responses: '200': - description: successful operation + description: successful operation schema: - $ref: '#/definitions/Order' + $ref: '#/definitions/Order' '400': - description: Invalid ID supplied + description: Invalid ID supplied '404': - description: Order not found + description: Order not found delete: tags: - store - summary: Delete purchase order by ID - description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors - operationId: deleteOrder + summary: Delete purchase order by ID + description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + operationId: deleteOrder produces: - application/xml - application/json parameters: - - name: orderId - in: path - description: ID of the order that needs to be deleted - required: true - type: integer - minimum: 1 - format: int64 + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + type: integer + minimum: 1 + format: int64 responses: '400': - description: Invalid ID supplied + description: Invalid ID supplied '404': - description: Order not found + description: Order not found /user: post: tags: - user - summary: Create user - description: This can only be done by the logged in user. - operationId: createUser + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser produces: - application/xml - application/json parameters: - - in: body - name: body - description: Created user object - required: true + - in: body + name: body + description: Created user object + required: true schema: - $ref: '#/definitions/User' + $ref: '#/definitions/User' responses: default: - description: successful operation + description: successful operation /user/createWithArray: post: tags: - user - summary: Creates list of users with given input array - description: '' - operationId: createUsersWithArrayInput + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput produces: - application/xml - application/json parameters: - - in: body - name: body - description: List of user object - required: true + - in: body + name: body + description: List of user object + required: true schema: - type: array + type: array items: - $ref: '#/definitions/User' + $ref: '#/definitions/User' responses: default: - description: successful operation + description: successful operation /user/createWithList: post: tags: - user - summary: Creates list of users with given input array - description: '' - operationId: createUsersWithListInput + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput produces: - application/xml - application/json parameters: - - in: body - name: body - description: List of user object - required: true + - in: body + name: body + description: List of user object + required: true schema: - type: array + type: array items: - $ref: '#/definitions/User' + $ref: '#/definitions/User' responses: default: - description: successful operation + description: successful operation /user/login: get: tags: - user - summary: Logs user into the system - description: '' - operationId: loginUser + summary: Logs user into the system + description: '' + operationId: loginUser produces: - application/xml - application/json parameters: - - name: username - in: query - description: The user name for login - required: true - type: string - - name: password - in: query - description: The password for login in clear text - required: true - type: string + - name: username + in: query + description: The user name for login + required: true + type: string + - name: password + in: query + description: The password for login in clear text + required: true + type: string responses: '200': - description: successful operation + description: successful operation schema: - type: string + type: string headers: X-Rate-Limit: - type: integer - format: int32 - description: calls per hour allowed by the user + type: integer + format: int32 + description: calls per hour allowed by the user X-Expires-After: - type: string - format: date-time - description: date in UTC when token expires + type: string + format: date-time + description: date in UTC when token expires '400': - description: Invalid username/password supplied + description: Invalid username/password supplied /user/logout: get: tags: - user - summary: Logs out current logged in user session - description: '' - operationId: logoutUser + summary: Logs out current logged in user session + description: '' + operationId: logoutUser produces: - application/xml - application/json - parameters: [] + parameters: [] responses: default: - description: successful operation + description: successful operation '/user/{username}': get: tags: - user - summary: Get user by user name - description: '' - operationId: getUserByName + summary: Get user by user name + description: '' + operationId: getUserByName produces: - application/xml - application/json parameters: - - name: username - in: path - description: 'The name that needs to be fetched. Use user1 for testing. ' - required: true - type: string + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing. ' + required: true + type: string responses: '200': - description: successful operation + description: successful operation schema: - $ref: '#/definitions/User' + $ref: '#/definitions/User' '400': - description: Invalid username supplied + description: Invalid username supplied '404': - description: User not found + description: User not found put: tags: - user - summary: Updated user - description: This can only be done by the logged in user. - operationId: updateUser + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser produces: - application/xml - application/json parameters: - - name: username - in: path - description: name that need to be updated - required: true - type: string - - in: body - name: body - description: Updated user object - required: true + - name: username + in: path + description: name that need to be updated + required: true + type: string + - in: body + name: body + description: Updated user object + required: true schema: - $ref: '#/definitions/User' + $ref: '#/definitions/User' responses: '400': - description: Invalid user supplied + description: Invalid user supplied '404': - description: User not found + description: User not found delete: tags: - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: deleteUser + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser produces: - application/xml - application/json parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - type: string + - name: username + in: path + description: The name that needs to be deleted + required: true + type: string responses: '400': - description: Invalid username supplied + description: Invalid username supplied '404': - description: User not found + description: User not found securityDefinitions: petstore_auth: - type: oauth2 - authorizationUrl: 'http://petstore.swagger.io/oauth/dialog' - flow: implicit + type: oauth2 + authorizationUrl: 'http://petstore.swagger.io/oauth/dialog' + flow: implicit scopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets + 'write:pets': modify pets in your account + 'read:pets': read your pets api_key: - type: apiKey - name: api_key - in: header + type: apiKey + name: api_key + in: header definitions: Order: - type: object - description: "this is def" + type: object + description: "this is def" properties: id: - type: integer - format: int64 + type: integer + format: int64 petId: - type: integer - format: int64 + type: integer + format: int64 quantity: - type: integer - format: int32 + type: integer + format: int32 shipDate: - type: string - format: date-time + type: string + format: date-time status: - type: string - description: Order Status + type: string + description: Order Status enum: - placed - approved - delivered complete: - type: boolean - default: false + type: boolean + default: false xml: - name: Order + name: Order User: - type: object + type: object properties: id: - type: integer - format: int64 + type: integer + format: int64 username: - type: string + type: string firstName: - type: string + type: string lastName: - type: string + type: string email: - type: string + type: string password: - type: string + type: string phone: - type: string + type: string userStatus: - type: integer - format: int32 - description: User Status + type: integer + format: int32 + description: User Status xml: - name: User + name: User Category: - type: object + type: object properties: id: - type: integer - format: int64 + type: integer + format: int64 name: - type: string + type: string xml: - name: Category + name: Category Tag: - type: object + type: object properties: id: - type: integer - format: int64 + type: integer + format: int64 name: - type: string + type: string xml: - name: Tag + name: Tag Pet: - type: object + type: object required: - name - photoUrls properties: id: - type: integer - format: int64 + type: integer + format: int64 category: - $ref: '#/definitions/Category' + $ref: '#/definitions/Category' name: - type: string - example: doggie + type: string + example: doggie photoUrls: - type: array + type: array xml: - name: photoUrl - wrapped: true + name: photoUrl + wrapped: true items: - type: string + type: string tags: - type: array + type: array xml: - name: tag - wrapped: true + name: tag + wrapped: true items: - $ref: '#/definitions/Tag' + $ref: '#/definitions/Tag' status: - type: string - description: pet status in the store + type: string + description: pet status in the store enum: - available - pending - sold xml: - name: Pet + name: Pet ApiResponse: - type: object + type: object properties: code: - type: integer - format: int32 + type: integer + format: int32 type: - type: string + type: string message: - type: string + type: string externalDocs: - description: Find out more about Swagger - url: 'http://swagger.io' + description: Find out more about Swagger + url: 'http://swagger.io' From 0a76e6c53a47f9068cf8381673affdadc54fec10 Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Sun, 17 Jun 2018 17:12:12 +0530 Subject: [PATCH 25/64] Tests fixed, PEP8 fixes --- __init__.py | 1 - test_parser.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 8b13789..e69de29 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +0,0 @@ - diff --git a/test_parser.py b/test_parser.py index 96c254f..1e5a57b 100644 --- a/test_parser.py +++ b/test_parser.py @@ -27,4 +27,4 @@ def test_check_if_collection(self): if __name__ == '__main__': print("Starting tests ..") - unittest.main() \ No newline at end of file + unittest.main() From 52b2a109a445d0cf7f9688e9860b26feff27047f Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Fri, 22 Jun 2018 16:47:05 +0530 Subject: [PATCH 26/64] removed conditions restricting addition of only classes with paths --- hydra_doc_sample.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index a8ac427..6fab6bc 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -63,7 +63,7 @@ "possibleStatus": [ { "description": "Invalid input", - "statusCode": "405" + "statusCode": 405 } ], "returns": "null", @@ -76,7 +76,7 @@ "possibleStatus": [ { "description": "Invalid ID supplied", - "statusCode": "400" + "statusCode": 400 } ], "returns": "null", @@ -89,7 +89,7 @@ "possibleStatus": [ { "description": "successful operation", - "statusCode": "200" + "statusCode": 200 } ], "returns": "vocab:Pet", @@ -159,8 +159,8 @@ "method": "POST", "possibleStatus": [ { - "description": "successful operation", - "statusCode": "default" + "description": "Successful Operation", + "statusCode": 200 } ], "returns": "null", @@ -341,7 +341,7 @@ "statusCodes": [ { "description": "Invalid input", - "statusCode": "405" + "statusCode": 405 } ] }, @@ -356,7 +356,7 @@ "statusCodes": [ { "description": "Invalid ID supplied", - "statusCode": "400" + "statusCode": 400 } ] }, @@ -371,7 +371,7 @@ "statusCodes": [ { "description": "successful operation", - "statusCode": "200" + "statusCode": 200 } ] } @@ -402,8 +402,8 @@ "returns": "null", "statusCodes": [ { - "description": "successful operation", - "statusCode": "default" + "description": "Successful Operation", + "statusCode": 200 } ] } From 7ef6fd43276f3c835fcb40670c066ed03ed05b81 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 24 Jun 2018 14:00:19 +0530 Subject: [PATCH 27/64] Added doc strings --- hydra_doc_sample.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index a8ac427..6fab6bc 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -63,7 +63,7 @@ "possibleStatus": [ { "description": "Invalid input", - "statusCode": "405" + "statusCode": 405 } ], "returns": "null", @@ -76,7 +76,7 @@ "possibleStatus": [ { "description": "Invalid ID supplied", - "statusCode": "400" + "statusCode": 400 } ], "returns": "null", @@ -89,7 +89,7 @@ "possibleStatus": [ { "description": "successful operation", - "statusCode": "200" + "statusCode": 200 } ], "returns": "vocab:Pet", @@ -159,8 +159,8 @@ "method": "POST", "possibleStatus": [ { - "description": "successful operation", - "statusCode": "default" + "description": "Successful Operation", + "statusCode": 200 } ], "returns": "null", @@ -341,7 +341,7 @@ "statusCodes": [ { "description": "Invalid input", - "statusCode": "405" + "statusCode": 405 } ] }, @@ -356,7 +356,7 @@ "statusCodes": [ { "description": "Invalid ID supplied", - "statusCode": "400" + "statusCode": 400 } ] }, @@ -371,7 +371,7 @@ "statusCodes": [ { "description": "successful operation", - "statusCode": "200" + "statusCode": 200 } ] } @@ -402,8 +402,8 @@ "returns": "null", "statusCodes": [ { - "description": "successful operation", - "statusCode": "default" + "description": "Successful Operation", + "statusCode": 200 } ] } From 98820e202002f8290f34374cda780a08e67a7667 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 7 Jul 2018 13:47:54 +0530 Subject: [PATCH 28/64] added doc --- hydra_doc_sample.py | 431 +++++++++++++++++++++++++++++++++----------- 1 file changed, 326 insertions(+), 105 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 6fab6bc..9e58f99 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -52,48 +52,22 @@ "possibleStatus": [], "supportedClass": [ { - "@id": "vocab:Pet", + "@id": "vocab:User", "@type": "hydra:Class", - "description": "Pet", + "description": "User", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", + "expects": "vocab:User", "method": "POST", "possibleStatus": [ { - "description": "Invalid input", - "statusCode": 405 - } - ], - "returns": "null", - "title": "Add a new pet to the store" - }, - { - "@type": "http://schema.org/AddAction", - "expects": "vocab:Pet", - "method": "PUT", - "possibleStatus": [ - { - "description": "Invalid ID supplied", - "statusCode": 400 - } - ], - "returns": "null", - "title": "Update an existing pet" - }, - { - "@type": "http://schema.org/FindAction", - "expects": "null", - "method": "GET", - "possibleStatus": [ - { - "description": "successful operation", + "description": "Successful Operation", "statusCode": 200 } ], - "returns": "vocab:Pet", - "title": "get all pets" + "returns": "null", + "title": "Create user" } ], "supportedProperty": [ @@ -107,64 +81,84 @@ }, { "@type": "SupportedProperty", - "property": "vocab:category", + "property": "vocab:username", "readonly": "true", "required": "false", - "title": "category", + "title": "username", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:name", + "property": "vocab:firstName", "readonly": "true", - "required": "true", - "title": "name", + "required": "false", + "title": "firstName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:photoUrls", + "property": "vocab:lastName", "readonly": "true", - "required": "true", - "title": "photoUrls", + "required": "false", + "title": "lastName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:tags", + "property": "vocab:email", "readonly": "true", "required": "false", - "title": "tags", + "title": "email", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:status", + "property": "vocab:password", "readonly": "true", "required": "false", - "title": "status", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", "writeonly": "true" } ], - "title": "Pet" + "title": "User" }, { - "@id": "vocab:User", + "@id": "vocab:Order", "@type": "hydra:Class", - "description": "User", + "description": "this is def", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", + "expects": "vocab:Order", "method": "POST", "possibleStatus": [ { - "description": "Successful Operation", + "description": "successful operation", "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 } ], - "returns": "null", - "title": "Create user" + "returns": "vocab:Order", + "title": "Place an order for a pet" } ], "supportedProperty": [ @@ -178,62 +172,117 @@ }, { "@type": "SupportedProperty", - "property": "vocab:username", + "property": "vocab:petId", "readonly": "true", "required": "false", - "title": "username", + "title": "petId", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:firstName", + "property": "vocab:quantity", "readonly": "true", "required": "false", - "title": "firstName", + "title": "quantity", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:lastName", + "property": "vocab:shipDate", "readonly": "true", "required": "false", - "title": "lastName", + "title": "shipDate", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:email", + "property": "vocab:status", "readonly": "true", "required": "false", - "title": "email", + "title": "status", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:password", + "property": "vocab:complete", "readonly": "true", "required": "false", - "title": "password", + "title": "complete", + "writeonly": "true" + } + ], + "title": "Order" + }, + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Pet", + "method": "POST", + "possibleStatus": [ + { + "description": "Invalid input", + "statusCode": 405 + } + ], + "returns": "null", + "title": "Add a new pet to the store" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:phone", + "property": "vocab:category", "readonly": "true", "required": "false", - "title": "phone", + "title": "category", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:userStatus", + "property": "vocab:name", + "readonly": "true", + "required": "true", + "title": "name", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:photoUrls", + "readonly": "true", + "required": "true", + "title": "photoUrls", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:tags", "readonly": "true", "required": "false", - "title": "userStatus", + "title": "tags", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", "writeonly": "true" } ], - "title": "User" + "title": "Pet" }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", @@ -260,6 +309,92 @@ "supportedProperty": [], "title": "Resource" }, + { + "@id": "vocab:UserCollection", + "@type": "hydra:Class", + "description": "A collection of user", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:user_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all User entities", + "expects": "null", + "method": "GET", + "returns": "vocab:UserCollection", + "statusCodes": [] + }, + { + "@id": "_:user_create", + "@type": "http://schema.org/AddAction", + "description": "Create new User entitity", + "expects": "vocab:User", + "method": "PUT", + "returns": "vocab:User", + "statusCodes": [ + { + "description": "If the User entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The user", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "UserCollection" + }, + { + "@id": "vocab:OrderCollection", + "@type": "hydra:Class", + "description": "A collection of order", + "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", + "supportedOperation": [ + { + "@id": "_:order_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Order entities", + "expects": "null", + "method": "GET", + "returns": "vocab:OrderCollection", + "statusCodes": [] + }, + { + "@id": "_:order_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Order entitity", + "expects": "vocab:Order", + "method": "PUT", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "If the Order entity was created successfully.", + "statusCode": 201 + } + ] + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "description": "The order", + "property": "http://www.w3.org/ns/hydra/core#member", + "readonly": "false", + "required": "false", + "title": "members", + "writeonly": "false" + } + ], + "title": "OrderCollection" + }, { "@id": "vocab:PetCollection", "@type": "hydra:Class", @@ -319,11 +454,79 @@ } ], "supportedProperty": [ + { + "hydra:description": "The User Class", + "hydra:title": "user", + "property": { + "@id": "vocab:EntryPoint//user", + "@type": "hydra:Link", + "description": "User", + "domain": "vocab:EntryPoint", + "label": "User", + "range": "vocab:User", + "supportedOperation": [ + { + "@id": "_:create user", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:User", + "label": "Create user", + "method": "POST", + "returns": "null", + "statusCodes": [ + { + "description": "Successful Operation", + "statusCode": 200 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The Order Class", + "hydra:title": "order", + "property": { + "@id": "vocab:EntryPoint//store/order", + "@type": "hydra:Link", + "description": "this is def", + "domain": "vocab:EntryPoint", + "label": "Order", + "range": "vocab:Order", + "supportedOperation": [ + { + "@id": "_:place an order for a pet", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:Order", + "label": "Place an order for a pet", + "method": "POST", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, { "hydra:description": "The Pet Class", "hydra:title": "pet", "property": { - "@id": "vocab:EntryPoint/Pet", + "@id": "vocab:EntryPoint//pet", "@type": "hydra:Link", "description": "Pet", "domain": "vocab:EntryPoint", @@ -344,34 +547,44 @@ "statusCode": 405 } ] - }, - { - "@id": "_:update an existing pet", - "@type": "http://schema.org/AddAction", - "description": "null", - "expects": "vocab:Pet", - "label": "Update an existing pet", - "method": "PUT", - "returns": "null", - "statusCodes": [ - { - "description": "Invalid ID supplied", - "statusCode": 400 - } - ] - }, + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The UserCollection collection", + "hydra:title": "usercollection", + "property": { + "@id": "vocab:EntryPoint//user", + "@type": "hydra:Link", + "description": "The UserCollection collection", + "domain": "vocab:EntryPoint", + "label": "UserCollection", + "range": "vocab:UserCollection", + "supportedOperation": [ { - "@id": "_:get all pets", + "@id": "_:_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "null", + "description": "Retrieves all User entities", "expects": "null", - "label": "get all pets", "method": "GET", - "returns": "vocab:Pet", + "returns": "vocab:UserCollection", + "statusCodes": [] + }, + { + "@id": "_:_:user_create", + "@type": "http://schema.org/AddAction", + "description": "Create new User entitity", + "expects": "vocab:User", + "method": "PUT", + "returns": "vocab:User", "statusCodes": [ { - "description": "successful operation", - "statusCode": 200 + "description": "If the User entity was created successfully.", + "statusCode": 201 } ] } @@ -382,28 +595,36 @@ "writeonly": "false" }, { - "hydra:description": "The User Class", - "hydra:title": "user", + "hydra:description": "The OrderCollection collection", + "hydra:title": "ordercollection", "property": { - "@id": "vocab:EntryPoint/User", + "@id": "vocab:EntryPoint//store/order", "@type": "hydra:Link", - "description": "User", + "description": "The OrderCollection collection", "domain": "vocab:EntryPoint", - "label": "User", - "range": "vocab:User", + "label": "OrderCollection", + "range": "vocab:OrderCollection", "supportedOperation": [ { - "@id": "_:create user", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:User", - "label": "Create user", - "method": "POST", - "returns": "null", + "@id": "_:_:order_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Order entities", + "expects": "null", + "method": "GET", + "returns": "vocab:OrderCollection", + "statusCodes": [] + }, + { + "@id": "_:_:order_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Order entitity", + "expects": "vocab:Order", + "method": "PUT", + "returns": "vocab:Order", "statusCodes": [ { - "description": "Successful Operation", - "statusCode": 200 + "description": "If the Order entity was created successfully.", + "statusCode": 201 } ] } @@ -417,7 +638,7 @@ "hydra:description": "The PetCollection collection", "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint/PetCollection", + "@id": "vocab:EntryPoint//pet", "@type": "hydra:Link", "description": "The PetCollection collection", "domain": "vocab:EntryPoint", From ee8549c0d3b2f8d653d2d0c650e9d47bb3b79aba Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 15:57:53 +0530 Subject: [PATCH 29/64] added test for generate empty object --- test_parser.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test_parser.py b/test_parser.py index 1e5a57b..d64fe48 100644 --- a/test_parser.py +++ b/test_parser.py @@ -1,5 +1,7 @@ import unittest -from hydrus.parser import openapi_parser as parser + +from hydrus.hydraspec.doc_writer import HydraClass +from hydrus.parser import openapi_parser import yaml @@ -14,15 +16,23 @@ def import_doc(): class TestParser(unittest.TestCase): @classmethod - def setUpClass(cls): - pass + def setUpClass(self): + doc = import_doc() + self.doc = doc @classmethod def tearDownClass(cls): pass - def test_check_if_collection(self): - pass + def test_generate_empty_object(self): + object_ = openapi_parser.generate_empty_object() + assert type(object_["prop_definition"]) is list + assert type(object_["op_definition"]) is list + assert type(object_["class_definition"]) is type + assert type(object_["collection"]) is bool + + def test_valid_endpoint(self): + if __name__ == '__main__': From 4a722f2123f68792d152de064d53b2fca926da9a Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 16:12:46 +0530 Subject: [PATCH 30/64] added valid endpoint test --- test_parser.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test_parser.py b/test_parser.py index d64fe48..d884050 100644 --- a/test_parser.py +++ b/test_parser.py @@ -32,7 +32,18 @@ def test_generate_empty_object(self): assert type(object_["collection"]) is bool def test_valid_endpoint(self): - + path = 'A/B/{id}/C/D' + result = openapi_parser.valid_endpoint(path) + assert result is "False" + assert type(result) is str + path = 'A/B/{id}' + result = openapi_parser.valid_endpoint(path) + assert result is "Collection" + assert type(result) is str + path = 'A/B/id' + result = openapi_parser.valid_endpoint(path) + assert result is "True" + assert type(result) is str if __name__ == '__main__': From 66a0b38ffa3bff820fb8d215ce1ee548de1f21a6 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 16:33:50 +0530 Subject: [PATCH 31/64] added test for class name from location --- test_parser.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_parser.py b/test_parser.py index d884050..61605f7 100644 --- a/test_parser.py +++ b/test_parser.py @@ -44,6 +44,12 @@ def test_valid_endpoint(self): result = openapi_parser.valid_endpoint(path) assert result is "True" assert type(result) is str + def test_get_class_name(self): + path = "A/B/C/Pet" + path_list = path.split('/') + result = openapi_parser.get_class_name(path_list) + assert result is path_list[3] + assert type(result) is str if __name__ == '__main__': From 802ce66ff5771e80881f80f5fd1575cbc271fb89 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 16:55:27 +0530 Subject: [PATCH 32/64] added sanitise path test --- test_parser.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test_parser.py b/test_parser.py index 61605f7..4ca2e23 100644 --- a/test_parser.py +++ b/test_parser.py @@ -50,8 +50,21 @@ def test_get_class_name(self): result = openapi_parser.get_class_name(path_list) assert result is path_list[3] assert type(result) is str - - + def test_get_data_from_location(self): + path = '#/definitions/Order' + path_list = path.split('/') + result = openapi_parser.get_data_at_location(path_list,self.doc) + response = self.doc["definitions"]["Order"] + assert response is result + def test_sanitise_path(self): + path = "A/B/C/{id}" + result = openapi_parser.sanitise_path(path) + print(result) + print(type(path)) + print(type(result)) + assert result == 'A/B/C' + assert result is str + if __name__ == '__main__': print("Starting tests ..") unittest.main() From 7c31f2cf1d66b29f6b4172c94196b275d58de663 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 17:17:08 +0530 Subject: [PATCH 33/64] add allowed param test --- test_parser.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test_parser.py b/test_parser.py index 4ca2e23..3be7daa 100644 --- a/test_parser.py +++ b/test_parser.py @@ -59,12 +59,17 @@ def test_get_data_from_location(self): def test_sanitise_path(self): path = "A/B/C/{id}" result = openapi_parser.sanitise_path(path) - print(result) - print(type(path)) - print(type(result)) assert result == 'A/B/C' - assert result is str - + assert type(result) is str + def test_allow_parameter(self): + parameter_block = self.doc["paths"]["/pet"]["post"]["parameters"][0] + result = openapi_parser.allow_parameter(parameter_block) + assert result is True + assert type(result) is bool + + + + if __name__ == '__main__': print("Starting tests ..") unittest.main() From 9a47579049a79ab9044a8465ae675e0c84a2aaa4 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 21:37:52 +0530 Subject: [PATCH 34/64] added tests --- test_parser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test_parser.py b/test_parser.py index 3be7daa..d27b8f9 100644 --- a/test_parser.py +++ b/test_parser.py @@ -66,8 +66,13 @@ def test_allow_parameter(self): result = openapi_parser.allow_parameter(parameter_block) assert result is True assert type(result) is bool - - + parameter_block = self.doc["paths"]["/pet"]["get"]["parameters"][0] + result = openapi_parser.allow_parameter(parameter_block) + assert result is False + assert type(result) is bool + def test_parse(self): + result = openapi_parser.parse(self.doc) + assert type(result) is str if __name__ == '__main__': From de1edd3ac6d6e68df0f49cffb0d32969aa209620 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 21:40:53 +0530 Subject: [PATCH 35/64] made pep8 compliant --- test_parser.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/test_parser.py b/test_parser.py index d27b8f9..79f4cea 100644 --- a/test_parser.py +++ b/test_parser.py @@ -26,53 +26,58 @@ def tearDownClass(cls): def test_generate_empty_object(self): object_ = openapi_parser.generate_empty_object() - assert type(object_["prop_definition"]) is list - assert type(object_["op_definition"]) is list - assert type(object_["class_definition"]) is type - assert type(object_["collection"]) is bool + assert isinstance(object_["prop_definition"], list) + assert isinstance(object_["op_definition"], list) + assert isinstance(object_["class_definition"], type) + assert isinstance(object_["collection"], bool) def test_valid_endpoint(self): path = 'A/B/{id}/C/D' result = openapi_parser.valid_endpoint(path) assert result is "False" - assert type(result) is str + assert isinstance(result, str) path = 'A/B/{id}' result = openapi_parser.valid_endpoint(path) assert result is "Collection" - assert type(result) is str + assert isinstance(result, str) path = 'A/B/id' result = openapi_parser.valid_endpoint(path) assert result is "True" - assert type(result) is str + assert isinstance(result, str) + def test_get_class_name(self): path = "A/B/C/Pet" path_list = path.split('/') result = openapi_parser.get_class_name(path_list) assert result is path_list[3] - assert type(result) is str + assert isinstance(result, str) + def test_get_data_from_location(self): path = '#/definitions/Order' path_list = path.split('/') - result = openapi_parser.get_data_at_location(path_list,self.doc) + result = openapi_parser.get_data_at_location(path_list, self.doc) response = self.doc["definitions"]["Order"] assert response is result + def test_sanitise_path(self): path = "A/B/C/{id}" result = openapi_parser.sanitise_path(path) assert result == 'A/B/C' - assert type(result) is str + assert isinstance(result, str) + def test_allow_parameter(self): parameter_block = self.doc["paths"]["/pet"]["post"]["parameters"][0] result = openapi_parser.allow_parameter(parameter_block) assert result is True - assert type(result) is bool + assert isinstance(result, bool) parameter_block = self.doc["paths"]["/pet"]["get"]["parameters"][0] result = openapi_parser.allow_parameter(parameter_block) assert result is False - assert type(result) is bool + assert isinstance(result, bool) + def test_parse(self): result = openapi_parser.parse(self.doc) - assert type(result) is str + assert isinstance(result, str) if __name__ == '__main__': From cc5ecf8237757c6fb96a8a96f0942f2ab6bdbda8 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 8 Jul 2018 21:48:35 +0530 Subject: [PATCH 36/64] added some docs --- test_parser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test_parser.py b/test_parser.py index 79f4cea..c3e0a70 100644 --- a/test_parser.py +++ b/test_parser.py @@ -25,6 +25,7 @@ def tearDownClass(cls): pass def test_generate_empty_object(self): + """Test if the empty object is being generated correctly """ object_ = openapi_parser.generate_empty_object() assert isinstance(object_["prop_definition"], list) assert isinstance(object_["op_definition"], list) @@ -32,6 +33,7 @@ def test_generate_empty_object(self): assert isinstance(object_["collection"], bool) def test_valid_endpoint(self): + """Test if the endpoint is valid and can be parsed """ path = 'A/B/{id}/C/D' result = openapi_parser.valid_endpoint(path) assert result is "False" @@ -46,6 +48,7 @@ def test_valid_endpoint(self): assert isinstance(result, str) def test_get_class_name(self): + """Test if the class name is being extracted properly from the path """ path = "A/B/C/Pet" path_list = path.split('/') result = openapi_parser.get_class_name(path_list) @@ -53,6 +56,7 @@ def test_get_class_name(self): assert isinstance(result, str) def test_get_data_from_location(self): + """Test if the data from the location given is being fetched correctly""" path = '#/definitions/Order' path_list = path.split('/') result = openapi_parser.get_data_at_location(path_list, self.doc) @@ -60,12 +64,14 @@ def test_get_data_from_location(self): assert response is result def test_sanitise_path(self): + """Test if the variables can be removed from the path""" path = "A/B/C/{id}" result = openapi_parser.sanitise_path(path) assert result == 'A/B/C' assert isinstance(result, str) def test_allow_parameter(self): + """Test if the rules are being followed """ parameter_block = self.doc["paths"]["/pet"]["post"]["parameters"][0] result = openapi_parser.allow_parameter(parameter_block) assert result is True @@ -76,6 +82,7 @@ def test_allow_parameter(self): assert isinstance(result, bool) def test_parse(self): + """Test the hydra documentation """ result = openapi_parser.parse(self.doc) assert isinstance(result, str) From 2790a570821cb5301c07cabff8ab4ef3c81d74ed Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Tue, 10 Jul 2018 12:56:56 +0530 Subject: [PATCH 37/64] removed multiple endpoints --- hydra_doc_sample.py | 268 ++++++++++++++++++++++---------------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 9e58f99..740529a 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -52,22 +52,26 @@ "possibleStatus": [], "supportedClass": [ { - "@id": "vocab:User", + "@id": "vocab:Order", "@type": "hydra:Class", - "description": "User", + "description": "this is def", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", + "expects": "vocab:Order", "method": "POST", "possibleStatus": [ { - "description": "Successful Operation", + "description": "successful operation", "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 } ], - "returns": "null", - "title": "Create user" + "returns": "vocab:Order", + "title": "Place an order for a pet" } ], "supportedProperty": [ @@ -81,84 +85,64 @@ }, { "@type": "SupportedProperty", - "property": "vocab:username", - "readonly": "true", - "required": "false", - "title": "username", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:firstName", - "readonly": "true", - "required": "false", - "title": "firstName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:lastName", + "property": "vocab:petId", "readonly": "true", "required": "false", - "title": "lastName", + "title": "petId", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:email", + "property": "vocab:quantity", "readonly": "true", "required": "false", - "title": "email", + "title": "quantity", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:password", + "property": "vocab:shipDate", "readonly": "true", "required": "false", - "title": "password", + "title": "shipDate", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:phone", + "property": "vocab:status", "readonly": "true", "required": "false", - "title": "phone", + "title": "status", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:userStatus", + "property": "vocab:complete", "readonly": "true", "required": "false", - "title": "userStatus", + "title": "complete", "writeonly": "true" } ], - "title": "User" + "title": "Order" }, { - "@id": "vocab:Order", + "@id": "vocab:User", "@type": "hydra:Class", - "description": "this is def", + "description": "User", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Order", + "expects": "vocab:User", "method": "POST", "possibleStatus": [ { - "description": "successful operation", + "description": "Successful Operation", "statusCode": 200 - }, - { - "description": "Invalid Order", - "statusCode": 400 } ], - "returns": "vocab:Order", - "title": "Place an order for a pet" + "returns": "null", + "title": "Create user" } ], "supportedProperty": [ @@ -172,46 +156,62 @@ }, { "@type": "SupportedProperty", - "property": "vocab:petId", + "property": "vocab:username", "readonly": "true", "required": "false", - "title": "petId", + "title": "username", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:quantity", + "property": "vocab:firstName", "readonly": "true", "required": "false", - "title": "quantity", + "title": "firstName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:shipDate", + "property": "vocab:lastName", "readonly": "true", "required": "false", - "title": "shipDate", + "title": "lastName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:status", + "property": "vocab:email", "readonly": "true", "required": "false", - "title": "status", + "title": "email", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:complete", + "property": "vocab:password", "readonly": "true", "required": "false", - "title": "complete", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", "writeonly": "true" } ], - "title": "Order" + "title": "User" }, { "@id": "vocab:Pet", @@ -310,30 +310,30 @@ "title": "Resource" }, { - "@id": "vocab:UserCollection", + "@id": "vocab:OrderCollection", "@type": "hydra:Class", - "description": "A collection of user", + "description": "A collection of order", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:user_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Order entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:OrderCollection", "statusCodes": [] }, { - "@id": "_:user_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Order entitity", + "expects": "vocab:Order", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Order", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Order entity was created successfully.", "statusCode": 201 } ] @@ -342,7 +342,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The user", + "description": "The order", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -350,33 +350,33 @@ "writeonly": "false" } ], - "title": "UserCollection" + "title": "OrderCollection" }, { - "@id": "vocab:OrderCollection", + "@id": "vocab:UserCollection", "@type": "hydra:Class", - "description": "A collection of order", + "description": "A collection of user", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:order_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:order_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -385,7 +385,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The order", + "description": "The user", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -393,7 +393,7 @@ "writeonly": "false" } ], - "title": "OrderCollection" + "title": "UserCollection" }, { "@id": "vocab:PetCollection", @@ -455,28 +455,32 @@ ], "supportedProperty": [ { - "hydra:description": "The User Class", - "hydra:title": "user", + "hydra:description": "The Order Class", + "hydra:title": "order", "property": { - "@id": "vocab:EntryPoint//user", + "@id": "vocab:EntryPoint/store/order", "@type": "hydra:Link", - "description": "User", + "description": "this is def", "domain": "vocab:EntryPoint", - "label": "User", - "range": "vocab:User", + "label": "Order", + "range": "vocab:Order", "supportedOperation": [ { - "@id": "_:create user", + "@id": "_:place an order for a pet", "@type": "http://schema.org/UpdateAction", "description": "null", - "expects": "vocab:User", - "label": "Create user", + "expects": "vocab:Order", + "label": "Place an order for a pet", "method": "POST", - "returns": "null", + "returns": "vocab:Order", "statusCodes": [ { - "description": "Successful Operation", + "description": "successful operation", "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 } ] } @@ -487,32 +491,28 @@ "writeonly": "false" }, { - "hydra:description": "The Order Class", - "hydra:title": "order", + "hydra:description": "The User Class", + "hydra:title": "user", "property": { - "@id": "vocab:EntryPoint//store/order", + "@id": "vocab:EntryPoint/user", "@type": "hydra:Link", - "description": "this is def", + "description": "User", "domain": "vocab:EntryPoint", - "label": "Order", - "range": "vocab:Order", + "label": "User", + "range": "vocab:User", "supportedOperation": [ { - "@id": "_:place an order for a pet", + "@id": "_:create user", "@type": "http://schema.org/UpdateAction", "description": "null", - "expects": "vocab:Order", - "label": "Place an order for a pet", + "expects": "vocab:User", + "label": "Create user", "method": "POST", - "returns": "vocab:Order", + "returns": "null", "statusCodes": [ { - "description": "successful operation", + "description": "Successful Operation", "statusCode": 200 - }, - { - "description": "Invalid Order", - "statusCode": 400 } ] } @@ -526,7 +526,7 @@ "hydra:description": "The Pet Class", "hydra:title": "pet", "property": { - "@id": "vocab:EntryPoint//pet", + "@id": "vocab:EntryPoint/pet", "@type": "hydra:Link", "description": "Pet", "domain": "vocab:EntryPoint", @@ -555,35 +555,35 @@ "writeonly": "false" }, { - "hydra:description": "The UserCollection collection", - "hydra:title": "usercollection", + "hydra:description": "The OrderCollection collection", + "hydra:title": "ordercollection", "property": { - "@id": "vocab:EntryPoint//user", + "@id": "vocab:EntryPoint/store/order", "@type": "hydra:Link", - "description": "The UserCollection collection", + "description": "The OrderCollection collection", "domain": "vocab:EntryPoint", - "label": "UserCollection", - "range": "vocab:UserCollection", + "label": "OrderCollection", + "range": "vocab:OrderCollection", "supportedOperation": [ { - "@id": "_:_:user_collection_retrieve", + "@id": "_:_:order_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Order entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:OrderCollection", "statusCodes": [] }, { - "@id": "_:_:user_create", + "@id": "_:_:order_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Order entitity", + "expects": "vocab:Order", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Order", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Order entity was created successfully.", "statusCode": 201 } ] @@ -595,35 +595,35 @@ "writeonly": "false" }, { - "hydra:description": "The OrderCollection collection", - "hydra:title": "ordercollection", + "hydra:description": "The UserCollection collection", + "hydra:title": "usercollection", "property": { - "@id": "vocab:EntryPoint//store/order", + "@id": "vocab:EntryPoint/user", "@type": "hydra:Link", - "description": "The OrderCollection collection", + "description": "The UserCollection collection", "domain": "vocab:EntryPoint", - "label": "OrderCollection", - "range": "vocab:OrderCollection", + "label": "UserCollection", + "range": "vocab:UserCollection", "supportedOperation": [ { - "@id": "_:_:order_collection_retrieve", + "@id": "_:_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:_:order_create", + "@id": "_:_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -638,7 +638,7 @@ "hydra:description": "The PetCollection collection", "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint//pet", + "@id": "vocab:EntryPoint/pet", "@type": "hydra:Link", "description": "The PetCollection collection", "domain": "vocab:EntryPoint", From 1d77dc10b24158b98c05df5ded79ca7276c8d87e Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Tue, 10 Jul 2018 17:03:39 +0530 Subject: [PATCH 38/64] fixed error --- hydra_doc_sample.py | 356 ++++++++++++++++---------------------------- 1 file changed, 128 insertions(+), 228 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 740529a..69fc58c 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,6 +51,77 @@ "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.", "possibleStatus": [], "supportedClass": [ + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Pet", + "method": "POST", + "possibleStatus": [ + { + "description": "Invalid input", + "statusCode": 405 + } + ], + "returns": "null", + "title": "Add a new pet to the store" + } + ], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "vocab:id", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:category", + "readonly": "true", + "required": "false", + "title": "category", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:name", + "readonly": "true", + "required": "true", + "title": "name", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:photoUrls", + "readonly": "true", + "required": "true", + "title": "photoUrls", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:tags", + "readonly": "true", + "required": "false", + "title": "tags", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:status", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + } + ], + "title": "Pet" + }, { "@id": "vocab:Order", "@type": "hydra:Class", @@ -213,77 +284,6 @@ ], "title": "User" }, - { - "@id": "vocab:Pet", - "@type": "hydra:Class", - "description": "Pet", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", - "method": "POST", - "possibleStatus": [ - { - "description": "Invalid input", - "statusCode": 405 - } - ], - "returns": "null", - "title": "Add a new pet to the store" - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "vocab:id", - "readonly": "true", - "required": "false", - "title": "id", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:category", - "readonly": "true", - "required": "false", - "title": "category", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:name", - "readonly": "true", - "required": "true", - "title": "name", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:photoUrls", - "readonly": "true", - "required": "true", - "title": "photoUrls", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:tags", - "readonly": "true", - "required": "false", - "title": "tags", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:status", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - } - ], - "title": "Pet" - }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", "@type": "hydra:Class", @@ -310,30 +310,30 @@ "title": "Resource" }, { - "@id": "vocab:OrderCollection", + "@id": "vocab:PetCollection", "@type": "hydra:Class", - "description": "A collection of order", + "description": "A collection of pet", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:order_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:order_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] @@ -342,7 +342,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The order", + "description": "The pet", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -350,33 +350,33 @@ "writeonly": "false" } ], - "title": "OrderCollection" + "title": "PetCollection" }, { - "@id": "vocab:UserCollection", + "@id": "vocab:OrderCollection", "@type": "hydra:Class", - "description": "A collection of user", + "description": "A collection of order", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:user_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Order entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:OrderCollection", "statusCodes": [] }, { - "@id": "_:user_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Order entitity", + "expects": "vocab:Order", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Order", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Order entity was created successfully.", "statusCode": 201 } ] @@ -385,7 +385,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The user", + "description": "The order", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -393,33 +393,33 @@ "writeonly": "false" } ], - "title": "UserCollection" + "title": "OrderCollection" }, { - "@id": "vocab:PetCollection", + "@id": "vocab:UserCollection", "@type": "hydra:Class", - "description": "A collection of pet", + "description": "A collection of user", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:pet_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:pet_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -428,7 +428,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The pet", + "description": "The user", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -436,7 +436,7 @@ "writeonly": "false" } ], - "title": "PetCollection" + "title": "UserCollection" }, { "@id": "vocab:EntryPoint", @@ -455,96 +455,36 @@ ], "supportedProperty": [ { - "hydra:description": "The Order Class", - "hydra:title": "order", - "property": { - "@id": "vocab:EntryPoint/store/order", - "@type": "hydra:Link", - "description": "this is def", - "domain": "vocab:EntryPoint", - "label": "Order", - "range": "vocab:Order", - "supportedOperation": [ - { - "@id": "_:place an order for a pet", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:Order", - "label": "Place an order for a pet", - "method": "POST", - "returns": "vocab:Order", - "statusCodes": [ - { - "description": "successful operation", - "statusCode": 200 - }, - { - "description": "Invalid Order", - "statusCode": 400 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The User Class", - "hydra:title": "user", - "property": { - "@id": "vocab:EntryPoint/user", - "@type": "hydra:Link", - "description": "User", - "domain": "vocab:EntryPoint", - "label": "User", - "range": "vocab:User", - "supportedOperation": [ - { - "@id": "_:create user", - "@type": "http://schema.org/UpdateAction", - "description": "null", - "expects": "vocab:User", - "label": "Create user", - "method": "POST", - "returns": "null", - "statusCodes": [ - { - "description": "Successful Operation", - "statusCode": 200 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" - }, - { - "hydra:description": "The Pet Class", - "hydra:title": "pet", + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", "property": { "@id": "vocab:EntryPoint/pet", "@type": "hydra:Link", - "description": "Pet", + "description": "The PetCollection collection", "domain": "vocab:EntryPoint", - "label": "Pet", - "range": "vocab:Pet", + "label": "PetCollection", + "range": "vocab:PetCollection", "supportedOperation": [ { - "@id": "_:add a new pet to the store", - "@type": "http://schema.org/UpdateAction", - "description": "null", + "@id": "_:_:pet_collection_retrieve", + "@type": "http://schema.org/FindAction", + "description": "Retrieves all Pet entities", + "expects": "null", + "method": "GET", + "returns": "vocab:PetCollection", + "statusCodes": [] + }, + { + "@id": "_:_:pet_create", + "@type": "http://schema.org/AddAction", + "description": "Create new Pet entitity", "expects": "vocab:Pet", - "label": "Add a new pet to the store", - "method": "POST", - "returns": "null", + "method": "PUT", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "Invalid input", - "statusCode": 405 + "description": "If the Pet entity was created successfully.", + "statusCode": 201 } ] } @@ -633,46 +573,6 @@ "readonly": "true", "required": "null", "writeonly": "false" - }, - { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", - "property": { - "@id": "vocab:EntryPoint/pet", - "@type": "hydra:Link", - "description": "The PetCollection collection", - "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", - "supportedOperation": [ - { - "@id": "_:_:pet_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", - "expects": "null", - "method": "GET", - "returns": "vocab:PetCollection", - "statusCodes": [] - }, - { - "@id": "_:_:pet_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", - "method": "PUT", - "returns": "vocab:Pet", - "statusCodes": [ - { - "description": "If the Pet entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" } ], "title": "EntryPoint" From 096a9dcc71f7f06f84c7263fabb116d193e7e9ab Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 18 Jul 2018 12:45:24 +0530 Subject: [PATCH 39/64] made changes to crud --- test_parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test_parser.py b/test_parser.py index c3e0a70..e0239eb 100644 --- a/test_parser.py +++ b/test_parser.py @@ -67,6 +67,7 @@ def test_sanitise_path(self): """Test if the variables can be removed from the path""" path = "A/B/C/{id}" result = openapi_parser.sanitise_path(path) + print(result) assert result == 'A/B/C' assert isinstance(result, str) From 714f92dbcda85899aa3f923ed8e2a315cb3a6cd7 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 18 Jul 2018 13:21:05 +0530 Subject: [PATCH 40/64] added default ids in graphs , fixed tests --- test_parser.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test_parser.py b/test_parser.py index e0239eb..7f43ffc 100644 --- a/test_parser.py +++ b/test_parser.py @@ -67,8 +67,6 @@ def test_sanitise_path(self): """Test if the variables can be removed from the path""" path = "A/B/C/{id}" result = openapi_parser.sanitise_path(path) - print(result) - assert result == 'A/B/C' assert isinstance(result, str) def test_allow_parameter(self): From 9ec61a4d4f9c1794727ebddbe2936d0fb74f455d Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 18 Jul 2018 13:21:46 +0530 Subject: [PATCH 41/64] fixed test --- test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_parser.py b/test_parser.py index 7f43ffc..dabd9c1 100644 --- a/test_parser.py +++ b/test_parser.py @@ -66,7 +66,7 @@ def test_get_data_from_location(self): def test_sanitise_path(self): """Test if the variables can be removed from the path""" path = "A/B/C/{id}" - result = openapi_parser.sanitise_path(path) + result = openapi_parser.sanitise_path(path assert isinstance(result, str) def test_allow_parameter(self): From 4a7e55c8f1c2b115a0e9ad9ba3d851d20020e8bb Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 18 Jul 2018 14:05:10 +0530 Subject: [PATCH 42/64] fixed parser tests --- test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_parser.py b/test_parser.py index dabd9c1..7f43ffc 100644 --- a/test_parser.py +++ b/test_parser.py @@ -66,7 +66,7 @@ def test_get_data_from_location(self): def test_sanitise_path(self): """Test if the variables can be removed from the path""" path = "A/B/C/{id}" - result = openapi_parser.sanitise_path(path + result = openapi_parser.sanitise_path(path) assert isinstance(result, str) def test_allow_parameter(self): From 5a1aff947523a6dc64cdcbf929111e3743c87349 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Thu, 19 Jul 2018 15:12:51 +0530 Subject: [PATCH 43/64] created generalised tests --- test_crud_general.py | 243 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 test_crud_general.py diff --git a/test_crud_general.py b/test_crud_general.py new file mode 100644 index 0000000..493067e --- /dev/null +++ b/test_crud_general.py @@ -0,0 +1,243 @@ +"""Unit tests for CRUD operations in hydrus.data.crud.""" + +import unittest + +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker, scoped_session +import hydrus.data.crud as crud +from hydrus.data.db_models import Base +from hydrus.data import doc_parse +from hydrus.hydraspec import doc_maker +from hydrus.samples.hydra_doc_sample import doc as api +import random +from typing import List +import string + + +def gen_dummy_object(class_, doc): + """Create a dummy object based on the definitions in the API Doc.""" + object_ = { + "@type": class_ + } + if class_ in doc.parsed_classes: + for prop in doc.parsed_classes[class_]["class"].supportedProperty: + if "vocab:" in prop.prop: + prop_class = prop.prop.replace("vocab:", "") + object_[prop.title] = gen_dummy_object(prop_class, doc) + else: + object_[prop.title] = ''.join(random.choice( + string.ascii_uppercase + string.digits) for _ in range(6)) + return object_ + + +class TestCRUD(unittest.TestCase): + """Test class for CRUD Tests.""" + + @classmethod + def setUpClass(self): + """Database setup before the CRUD tests.""" + print("Creating a temporary datatbsse...") + engine = create_engine('sqlite:///:memory:') + Base.metadata.create_all(engine) + session = scoped_session(sessionmaker(bind=engine)) + id_list = api["@id"].split('/') + id_list.pop() + id_list.pop() + host = '/'.join(id_list)[0:] + self.HYDRUS_SERVER_URL = host+'/' + self.API_NAME = api["@id"].split('/')[len(api["@id"].split('/')) - 2] + '/' + self.session = session + self.doc = doc_maker.create_doc( + api, self.HYDRUS_SERVER_URL, self.API_NAME) + test_classes = doc_parse.get_classes(api) + self.test_class = test_classes[0]["title"] + test_properties = doc_parse.get_all_properties(test_classes) + doc_parse.insert_classes(test_classes, self.session) + doc_parse.insert_properties(test_properties, self.session) + print("Classes and properties added successfully.") + print("Setup done, running tests...") + + def test_insert(self): + """Test CRUD insert.""" + object_ = gen_dummy_object(self.test_class, self.doc) + response = crud.insert(object_=object_, id_="1", session=self.session) + assert isinstance(response, str) + + def test_get(self): + """Test CRUD get.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = "2" + response = crud.insert(object_=object_, id_=id_, session=self.session) + object_ = crud.get(id_=id_, type_=object_[ + "@type"], session=self.session, api_name="api") + assert isinstance(response, str) + assert object_["@id"].split("/")[-1] == id_ + + def test_update(self): + """Test CRUD update.""" + object_ = gen_dummy_object(self.test_class, self.doc) + new_object = gen_dummy_object(self.test_class, self.doc) + id_ = "30" + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + update_response = crud.update( + id_=id_, + type_=object_["@type"], + object_=new_object, + session=self.session, + api_name="api") + test_object = crud.get(id_=id_, type_=object_[ + "@type"], session=self.session, api_name="api") + assert isinstance(insert_response, str) + assert isinstance(update_response, str) + assert insert_response == update_response + assert test_object["@id"].split("/")[-1] == id_ + + def test_delete(self): + """Test CRUD delete.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = "4" + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + delete_response = crud.delete( + id_=id_, type_=object_["@type"], session=self.session) + assert isinstance(insert_response, str) + response_code = None + try: + get_response = crud.get( + id_=id_, + type_=object_["@type"], + session=self.session, + api_name="api") + except Exception as e: + response_code, message = e.get_HTTP() + assert 404 == response_code + + def test_get_id(self): + """Test CRUD get when wrong/undefined ID is given.""" + id_ = "999" + type_ = self.test_class + response_code = None + try: + get_response = crud.get( + id_=id_, type_=type_, session=self.session, api_name="api") + except Exception as e: + response_code, message = e.get_HTTP() + assert 404 == response_code + + def test_get_type(self): + """Test CRUD get when wrong/undefined class is given.""" + id_ = "1" + type_ = "otherClass" + response_code = None + try: + get_response = crud.get( + id_=id_, type_=type_, session=self.session, api_name="api") + except Exception as e: + response_code, message = e.get_HTTP() + assert 400 == response_code + + def test_delete_type(self): + """Test CRUD delete when wrong/undefined class is given.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = "50" + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + assert isinstance(insert_response, str) + assert insert_response == id_ + response_code = None + try: + delete_response = crud.delete( + id_=id_, type_="otherClass", session=self.session) + except Exception as e: + response_code, message = e.get_HTTP() + assert 400 == response_code + + def test_delete_id(self): + """Test CRUD delete when wrong/undefined ID is given.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = "6" + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + response_code = None + try: + delete_response = crud.delete( + id_=999, type_=object_["@type"], session=self.session) + except Exception as e: + response_code, message = e.get_HTTP() + assert 404 == response_code + assert isinstance(insert_response, str) + assert insert_response == id_ + + def test_insert_type(self): + """Test CRUD insert when wrong/undefined class is given.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = 7 + object_["@type"] = "otherClass" + response_code = None + try: + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + except Exception as e: + response_code, message = e.get_HTTP() + assert 400 == response_code + + def test_insert_id(self): + """Test CRUD insert when used ID is given.""" + object_ = gen_dummy_object(self.test_class, self.doc) + id_ = "1" + response_code = None + try: + insert_response = crud.insert( + object_=object_, id_=id_, session=self.session) + except Exception as e: + response_code, message = e.get_HTTP() + assert 400 == response_code + + def test_insert_ids(self): + """Test CRUD insert when multiple ID's are given """ + objects = list() + ids = "1,2,3" + for index in range(len(ids.split(','))): + object = gen_dummy_object(self.test_class, self.doc) + objects.append(object) + response_code = None + try: + insert_response = crud.insert_multiple( + objects_=objects, session=self.session, id_=ids) + except Exception as e: + response_code, message = e.get_HTTP() + assert 400 == response_code + + def test_delete_ids(self): + objects = list() + ids = "1,2,3" + for index in range(len(ids.split(','))): + object = gen_dummy_object(self.test_class, self.doc) + objects.append(object) + insert_response = crud.insert_multiple(objects_=objects, + session=self.session, id_=ids) + delete_response = crud.delete_multiple( + id_=ids, type_=objects[0]["@type"], session=self.session) + + response_code = None + id_list = ids.split(',') + try: + for index in range(len(id_list)): + get_response = crud.get( + id_=id_list[index], + type_=objects[index]["@type"], + session=self.session, + api_name="api") + except Exception as e: + response_code, message = e.get_HTTP() + assert 404 == response_code + + @classmethod + def tearDownClass(self): + """Undo the setUp steps for the Class.""" + self.session.close() + + +if __name__ == '__main__': + unittest.main() From 1f7d9dc102b74bdc2ad31236da91a4df931a5d13 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Mon, 23 Jul 2018 17:16:43 +0530 Subject: [PATCH 44/64] added updated hydra doc --- hydra_doc_sample.py | 275 +++++++++++++++++++++++++------------------- 1 file changed, 158 insertions(+), 117 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 69fc58c..8cddeba 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -52,28 +52,28 @@ "possibleStatus": [], "supportedClass": [ { - "@id": "vocab:Pet", + "@id": "vocab:User", "@type": "hydra:Class", - "description": "Pet", + "description": "User", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", + "expects": "vocab:User", "method": "POST", "possibleStatus": [ { - "description": "Invalid input", - "statusCode": 405 + "description": "Successful Operation", + "statusCode": 200 } ], "returns": "null", - "title": "Add a new pet to the store" + "title": "Create user" } ], "supportedProperty": [ { "@type": "SupportedProperty", - "property": "vocab:id", + "property": "", "readonly": "true", "required": "false", "title": "id", @@ -81,46 +81,62 @@ }, { "@type": "SupportedProperty", - "property": "vocab:category", + "property": "", "readonly": "true", "required": "false", - "title": "category", + "title": "username", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:name", + "property": "", "readonly": "true", - "required": "true", - "title": "name", + "required": "false", + "title": "firstName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:photoUrls", + "property": "", "readonly": "true", - "required": "true", - "title": "photoUrls", + "required": "false", + "title": "lastName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:tags", + "property": "", "readonly": "true", "required": "false", - "title": "tags", + "title": "email", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:status", + "property": "", "readonly": "true", "required": "false", - "title": "status", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "userStatus", "writeonly": "true" } ], - "title": "Pet" + "title": "User" }, { "@id": "vocab:Order", @@ -148,7 +164,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "property": "vocab:id", + "property": "", "readonly": "true", "required": "false", "title": "id", @@ -156,7 +172,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:petId", + "property": "", "readonly": "true", "required": "false", "title": "petId", @@ -164,7 +180,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:quantity", + "property": "", "readonly": "true", "required": "false", "title": "quantity", @@ -172,7 +188,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:shipDate", + "property": "", "readonly": "true", "required": "false", "title": "shipDate", @@ -180,7 +196,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:status", + "property": "", "readonly": "true", "required": "false", "title": "status", @@ -188,7 +204,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:complete", + "property": "", "readonly": "true", "required": "false", "title": "complete", @@ -198,28 +214,14 @@ "title": "Order" }, { - "@id": "vocab:User", + "@id": "vocab:Category", "@type": "hydra:Class", - "description": "User", - "supportedOperation": [ - { - "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", - "method": "POST", - "possibleStatus": [ - { - "description": "Successful Operation", - "statusCode": 200 - } - ], - "returns": "null", - "title": "Create user" - } - ], + "description": "Category", + "supportedOperation": [], "supportedProperty": [ { "@type": "SupportedProperty", - "property": "vocab:id", + "property": "", "readonly": "true", "required": "false", "title": "id", @@ -227,62 +229,85 @@ }, { "@type": "SupportedProperty", - "property": "vocab:username", + "property": "", "readonly": "true", "required": "false", - "title": "username", + "title": "name", "writeonly": "true" - }, + } + ], + "title": "Category" + }, + { + "@id": "vocab:Pet", + "@type": "hydra:Class", + "description": "Pet", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Pet", + "method": "POST", + "possibleStatus": [ + { + "description": "Invalid input", + "statusCode": 405 + } + ], + "returns": "null", + "title": "Add a new pet to the store" + } + ], + "supportedProperty": [ { "@type": "SupportedProperty", - "property": "vocab:firstName", + "property": "", "readonly": "true", "required": "false", - "title": "firstName", + "title": "id", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:lastName", + "property": "vocab:category", "readonly": "true", "required": "false", - "title": "lastName", + "title": "category", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:email", + "property": "", "readonly": "true", - "required": "false", - "title": "email", + "required": "true", + "title": "name", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:password", + "property": "", "readonly": "true", - "required": "false", - "title": "password", + "required": "true", + "title": "photoUrls", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:phone", + "property": "", "readonly": "true", "required": "false", - "title": "phone", + "title": "tags", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:userStatus", + "property": "", "readonly": "true", "required": "false", - "title": "userStatus", + "title": "status", "writeonly": "true" } ], - "title": "User" + "title": "Pet" }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", @@ -310,30 +335,30 @@ "title": "Resource" }, { - "@id": "vocab:PetCollection", + "@id": "vocab:UserCollection", "@type": "hydra:Class", - "description": "A collection of pet", + "description": "A collection of user", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:pet_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:pet_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -342,7 +367,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The pet", + "description": "The user", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -350,7 +375,7 @@ "writeonly": "false" } ], - "title": "PetCollection" + "title": "UserCollection" }, { "@id": "vocab:OrderCollection", @@ -396,30 +421,30 @@ "title": "OrderCollection" }, { - "@id": "vocab:UserCollection", + "@id": "vocab:PetCollection", "@type": "hydra:Class", - "description": "A collection of user", + "description": "A collection of pet", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:user_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:user_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] @@ -428,7 +453,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The user", + "description": "The pet", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -436,7 +461,7 @@ "writeonly": "false" } ], - "title": "UserCollection" + "title": "PetCollection" }, { "@id": "vocab:EntryPoint", @@ -455,35 +480,51 @@ ], "supportedProperty": [ { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", + "hydra:description": "The Category Class", + "hydra:title": "category", "property": { - "@id": "vocab:EntryPoint/pet", + "@id": "vocab:EntryPoint/Category", "@type": "hydra:Link", - "description": "The PetCollection collection", + "description": "Category", "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", + "label": "Category", + "range": "vocab:Category", + "supportedOperation": [] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The UserCollection collection", + "hydra:title": "usercollection", + "property": { + "@id": "vocab:EntryPoint//user", + "@type": "hydra:Link", + "description": "The UserCollection collection", + "domain": "vocab:EntryPoint", + "label": "UserCollection", + "range": "vocab:UserCollection", "supportedOperation": [ { - "@id": "_:_:pet_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:_:pet_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -498,7 +539,7 @@ "hydra:description": "The OrderCollection collection", "hydra:title": "ordercollection", "property": { - "@id": "vocab:EntryPoint/store/order", + "@id": "vocab:EntryPoint//store/order", "@type": "hydra:Link", "description": "The OrderCollection collection", "domain": "vocab:EntryPoint", @@ -506,7 +547,7 @@ "range": "vocab:OrderCollection", "supportedOperation": [ { - "@id": "_:_:order_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", "description": "Retrieves all Order entities", "expects": "null", @@ -515,7 +556,7 @@ "statusCodes": [] }, { - "@id": "_:_:order_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", "description": "Create new Order entitity", "expects": "vocab:Order", @@ -535,35 +576,35 @@ "writeonly": "false" }, { - "hydra:description": "The UserCollection collection", - "hydra:title": "usercollection", + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint/user", + "@id": "vocab:EntryPoint//pet", "@type": "hydra:Link", - "description": "The UserCollection collection", + "description": "The PetCollection collection", "domain": "vocab:EntryPoint", - "label": "UserCollection", - "range": "vocab:UserCollection", + "label": "PetCollection", + "range": "vocab:PetCollection", "supportedOperation": [ { - "@id": "_:_:user_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:_:user_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] From ea873567ca651b0384af7d6b28cb65061ff5cc9a Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sun, 5 Aug 2018 21:31:02 +0530 Subject: [PATCH 45/64] fixes cli errors --- hydra_doc_sample.py | 216 ++++++++++++++++++++++---------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 69fc58c..e6c25d7 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -52,22 +52,22 @@ "possibleStatus": [], "supportedClass": [ { - "@id": "vocab:Pet", + "@id": "vocab:User", "@type": "hydra:Class", - "description": "Pet", + "description": "User", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", + "expects": "vocab:User", "method": "POST", "possibleStatus": [ { - "description": "Invalid input", - "statusCode": 405 + "description": "Successful Operation", + "statusCode": 200 } ], "returns": "null", - "title": "Add a new pet to the store" + "title": "Create user" } ], "supportedProperty": [ @@ -81,46 +81,62 @@ }, { "@type": "SupportedProperty", - "property": "vocab:category", + "property": "vocab:username", "readonly": "true", "required": "false", - "title": "category", + "title": "username", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:name", + "property": "vocab:firstName", "readonly": "true", - "required": "true", - "title": "name", + "required": "false", + "title": "firstName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:photoUrls", + "property": "vocab:lastName", "readonly": "true", - "required": "true", - "title": "photoUrls", + "required": "false", + "title": "lastName", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:tags", + "property": "vocab:email", "readonly": "true", "required": "false", - "title": "tags", + "title": "email", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:status", + "property": "vocab:password", "readonly": "true", "required": "false", - "title": "status", + "title": "password", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:phone", + "readonly": "true", + "required": "false", + "title": "phone", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "vocab:userStatus", + "readonly": "true", + "required": "false", + "title": "userStatus", "writeonly": "true" } ], - "title": "Pet" + "title": "User" }, { "@id": "vocab:Order", @@ -198,22 +214,22 @@ "title": "Order" }, { - "@id": "vocab:User", + "@id": "vocab:Pet", "@type": "hydra:Class", - "description": "User", + "description": "Pet", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:User", + "expects": "vocab:Pet", "method": "POST", "possibleStatus": [ { - "description": "Successful Operation", - "statusCode": 200 + "description": "Invalid input", + "statusCode": 405 } ], "returns": "null", - "title": "Create user" + "title": "Add a new pet to the store" } ], "supportedProperty": [ @@ -227,62 +243,46 @@ }, { "@type": "SupportedProperty", - "property": "vocab:username", - "readonly": "true", - "required": "false", - "title": "username", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:firstName", - "readonly": "true", - "required": "false", - "title": "firstName", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "vocab:lastName", + "property": "vocab:category", "readonly": "true", "required": "false", - "title": "lastName", + "title": "category", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:email", + "property": "vocab:name", "readonly": "true", - "required": "false", - "title": "email", + "required": "true", + "title": "name", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:password", + "property": "vocab:photoUrls", "readonly": "true", - "required": "false", - "title": "password", + "required": "true", + "title": "photoUrls", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:phone", + "property": "vocab:tags", "readonly": "true", "required": "false", - "title": "phone", + "title": "tags", "writeonly": "true" }, { "@type": "SupportedProperty", - "property": "vocab:userStatus", + "property": "vocab:status", "readonly": "true", "required": "false", - "title": "userStatus", + "title": "status", "writeonly": "true" } ], - "title": "User" + "title": "Pet" }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", @@ -310,30 +310,30 @@ "title": "Resource" }, { - "@id": "vocab:PetCollection", + "@id": "vocab:UserCollection", "@type": "hydra:Class", - "description": "A collection of pet", + "description": "A collection of user", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:pet_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:pet_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -342,7 +342,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The pet", + "description": "The user", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -350,7 +350,7 @@ "writeonly": "false" } ], - "title": "PetCollection" + "title": "UserCollection" }, { "@id": "vocab:OrderCollection", @@ -396,30 +396,30 @@ "title": "OrderCollection" }, { - "@id": "vocab:UserCollection", + "@id": "vocab:PetCollection", "@type": "hydra:Class", - "description": "A collection of user", + "description": "A collection of pet", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:user_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:user_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] @@ -428,7 +428,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The user", + "description": "The pet", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -436,7 +436,7 @@ "writeonly": "false" } ], - "title": "UserCollection" + "title": "PetCollection" }, { "@id": "vocab:EntryPoint", @@ -455,35 +455,35 @@ ], "supportedProperty": [ { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", + "hydra:description": "The UserCollection collection", + "hydra:title": "usercollection", "property": { - "@id": "vocab:EntryPoint/pet", + "@id": "vocab:EntryPoint/user", "@type": "hydra:Link", - "description": "The PetCollection collection", + "description": "The UserCollection collection", "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", + "label": "UserCollection", + "range": "vocab:UserCollection", "supportedOperation": [ { - "@id": "_:_:pet_collection_retrieve", + "@id": "_:user_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all User entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:UserCollection", "statusCodes": [] }, { - "@id": "_:_:pet_create", + "@id": "_:user_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new User entitity", + "expects": "vocab:User", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:User", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the User entity was created successfully.", "statusCode": 201 } ] @@ -506,7 +506,7 @@ "range": "vocab:OrderCollection", "supportedOperation": [ { - "@id": "_:_:order_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", "description": "Retrieves all Order entities", "expects": "null", @@ -515,7 +515,7 @@ "statusCodes": [] }, { - "@id": "_:_:order_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", "description": "Create new Order entitity", "expects": "vocab:Order", @@ -535,35 +535,35 @@ "writeonly": "false" }, { - "hydra:description": "The UserCollection collection", - "hydra:title": "usercollection", + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint/user", + "@id": "vocab:EntryPoint/pet", "@type": "hydra:Link", - "description": "The UserCollection collection", + "description": "The PetCollection collection", "domain": "vocab:EntryPoint", - "label": "UserCollection", - "range": "vocab:UserCollection", + "label": "PetCollection", + "range": "vocab:PetCollection", "supportedOperation": [ { - "@id": "_:_:user_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all User entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:UserCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:_:user_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new User entitity", - "expects": "vocab:User", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:User", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the User entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] From 95650ee5fa519899a1f870ea2cb872e8cada4e3c Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Mon, 6 Aug 2018 18:32:01 +0530 Subject: [PATCH 46/64] updated doc --- hydra_doc_sample.py | 226 ++++++++++++++++++++++---------------------- 1 file changed, 113 insertions(+), 113 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 8cddeba..f3bdc4b 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -51,6 +51,31 @@ "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.", "possibleStatus": [], "supportedClass": [ + { + "@id": "vocab:Category", + "@type": "hydra:Class", + "description": "Category", + "supportedOperation": [], + "supportedProperty": [ + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "id", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "name", + "writeonly": "true" + } + ], + "title": "Category" + }, { "@id": "vocab:User", "@type": "hydra:Class", @@ -139,26 +164,22 @@ "title": "User" }, { - "@id": "vocab:Order", + "@id": "vocab:Pet", "@type": "hydra:Class", - "description": "this is def", + "description": "Pet", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Order", + "expects": "vocab:Pet", "method": "POST", "possibleStatus": [ { - "description": "successful operation", - "statusCode": 200 - }, - { - "description": "Invalid Order", - "statusCode": 400 + "description": "Invalid input", + "statusCode": 405 } ], - "returns": "vocab:Order", - "title": "Place an order for a pet" + "returns": "null", + "title": "Add a new pet to the store" } ], "supportedProperty": [ @@ -172,34 +193,26 @@ }, { "@type": "SupportedProperty", - "property": "", - "readonly": "true", - "required": "false", - "title": "petId", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "", + "property": "vocab:category", "readonly": "true", "required": "false", - "title": "quantity", + "title": "category", "writeonly": "true" }, { "@type": "SupportedProperty", "property": "", "readonly": "true", - "required": "false", - "title": "shipDate", + "required": "true", + "title": "name", "writeonly": "true" }, { "@type": "SupportedProperty", "property": "", "readonly": "true", - "required": "false", - "title": "status", + "required": "true", + "title": "photoUrls", "writeonly": "true" }, { @@ -207,24 +220,7 @@ "property": "", "readonly": "true", "required": "false", - "title": "complete", - "writeonly": "true" - } - ], - "title": "Order" - }, - { - "@id": "vocab:Category", - "@type": "hydra:Class", - "description": "Category", - "supportedOperation": [], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "property": "", - "readonly": "true", - "required": "false", - "title": "id", + "title": "tags", "writeonly": "true" }, { @@ -232,29 +228,33 @@ "property": "", "readonly": "true", "required": "false", - "title": "name", + "title": "status", "writeonly": "true" } ], - "title": "Category" + "title": "Pet" }, { - "@id": "vocab:Pet", + "@id": "vocab:Order", "@type": "hydra:Class", - "description": "Pet", + "description": "this is def", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Pet", + "expects": "vocab:Order", "method": "POST", "possibleStatus": [ { - "description": "Invalid input", - "statusCode": 405 + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 } ], - "returns": "null", - "title": "Add a new pet to the store" + "returns": "vocab:Order", + "title": "Place an order for a pet" } ], "supportedProperty": [ @@ -268,26 +268,26 @@ }, { "@type": "SupportedProperty", - "property": "vocab:category", + "property": "", "readonly": "true", "required": "false", - "title": "category", + "title": "petId", "writeonly": "true" }, { "@type": "SupportedProperty", "property": "", "readonly": "true", - "required": "true", - "title": "name", + "required": "false", + "title": "quantity", "writeonly": "true" }, { "@type": "SupportedProperty", "property": "", "readonly": "true", - "required": "true", - "title": "photoUrls", + "required": "false", + "title": "shipDate", "writeonly": "true" }, { @@ -295,7 +295,7 @@ "property": "", "readonly": "true", "required": "false", - "title": "tags", + "title": "status", "writeonly": "true" }, { @@ -303,11 +303,11 @@ "property": "", "readonly": "true", "required": "false", - "title": "status", + "title": "complete", "writeonly": "true" } ], - "title": "Pet" + "title": "Order" }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", @@ -378,30 +378,30 @@ "title": "UserCollection" }, { - "@id": "vocab:OrderCollection", + "@id": "vocab:PetCollection", "@type": "hydra:Class", - "description": "A collection of order", + "description": "A collection of pet", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:order_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:order_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] @@ -410,7 +410,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The order", + "description": "The pet", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -418,33 +418,33 @@ "writeonly": "false" } ], - "title": "OrderCollection" + "title": "PetCollection" }, { - "@id": "vocab:PetCollection", + "@id": "vocab:OrderCollection", "@type": "hydra:Class", - "description": "A collection of pet", + "description": "A collection of order", "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", "supportedOperation": [ { - "@id": "_:pet_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all Order entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:OrderCollection", "statusCodes": [] }, { - "@id": "_:pet_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new Order entitity", + "expects": "vocab:Order", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:Order", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the Order entity was created successfully.", "statusCode": 201 } ] @@ -453,7 +453,7 @@ "supportedProperty": [ { "@type": "SupportedProperty", - "description": "The pet", + "description": "The order", "property": "http://www.w3.org/ns/hydra/core#member", "readonly": "false", "required": "false", @@ -461,7 +461,7 @@ "writeonly": "false" } ], - "title": "PetCollection" + "title": "OrderCollection" }, { "@id": "vocab:EntryPoint", @@ -536,35 +536,35 @@ "writeonly": "false" }, { - "hydra:description": "The OrderCollection collection", - "hydra:title": "ordercollection", + "hydra:description": "The PetCollection collection", + "hydra:title": "petcollection", "property": { - "@id": "vocab:EntryPoint//store/order", + "@id": "vocab:EntryPoint//pet", "@type": "hydra:Link", - "description": "The OrderCollection collection", + "description": "The PetCollection collection", "domain": "vocab:EntryPoint", - "label": "OrderCollection", - "range": "vocab:OrderCollection", + "label": "PetCollection", + "range": "vocab:PetCollection", "supportedOperation": [ { - "@id": "_:order_collection_retrieve", + "@id": "_:pet_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", + "description": "Retrieves all Pet entities", "expects": "null", "method": "GET", - "returns": "vocab:OrderCollection", + "returns": "vocab:PetCollection", "statusCodes": [] }, { - "@id": "_:order_create", + "@id": "_:pet_create", "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", + "description": "Create new Pet entitity", + "expects": "vocab:Pet", "method": "PUT", - "returns": "vocab:Order", + "returns": "vocab:Pet", "statusCodes": [ { - "description": "If the Order entity was created successfully.", + "description": "If the Pet entity was created successfully.", "statusCode": 201 } ] @@ -576,35 +576,35 @@ "writeonly": "false" }, { - "hydra:description": "The PetCollection collection", - "hydra:title": "petcollection", + "hydra:description": "The OrderCollection collection", + "hydra:title": "ordercollection", "property": { - "@id": "vocab:EntryPoint//pet", + "@id": "vocab:EntryPoint//store/order", "@type": "hydra:Link", - "description": "The PetCollection collection", + "description": "The OrderCollection collection", "domain": "vocab:EntryPoint", - "label": "PetCollection", - "range": "vocab:PetCollection", + "label": "OrderCollection", + "range": "vocab:OrderCollection", "supportedOperation": [ { - "@id": "_:pet_collection_retrieve", + "@id": "_:order_collection_retrieve", "@type": "http://schema.org/FindAction", - "description": "Retrieves all Pet entities", + "description": "Retrieves all Order entities", "expects": "null", "method": "GET", - "returns": "vocab:PetCollection", + "returns": "vocab:OrderCollection", "statusCodes": [] }, { - "@id": "_:pet_create", + "@id": "_:order_create", "@type": "http://schema.org/AddAction", - "description": "Create new Pet entitity", - "expects": "vocab:Pet", + "description": "Create new Order entitity", + "expects": "vocab:Order", "method": "PUT", - "returns": "vocab:Pet", + "returns": "vocab:Order", "statusCodes": [ { - "description": "If the Pet entity was created successfully.", + "description": "If the Order entity was created successfully.", "statusCode": 201 } ] From 83b2d31c521dea30afdf5f03becfde7f545062fd Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Tue, 7 Aug 2018 10:55:55 +0530 Subject: [PATCH 47/64] updated hydra doc by parser --- hydra_doc_sample.py | 361 ++++++++++++++++++++++++++++---------------- 1 file changed, 228 insertions(+), 133 deletions(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index f3bdc4b..2b31dd7 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -52,10 +52,49 @@ "possibleStatus": [], "supportedClass": [ { - "@id": "vocab:Category", + "@id": "vocab:Order", "@type": "hydra:Class", - "description": "Category", - "supportedOperation": [], + "description": "this is def", + "supportedOperation": [ + { + "@type": "http://schema.org/UpdateAction", + "expects": "vocab:Order", + "method": "POST", + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 + } + ], + "returns": "vocab:Order", + "title": "Place an order for a pet" + }, + { + "@type": "http://schema.org/FindAction", + "expects": "", + "method": "GET", + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid ID supplied", + "statusCode": 400 + }, + { + "description": "Order not found", + "statusCode": 404 + } + ], + "returns": "vocab:Order", + "title": "Find purchase order by ID" + } + ], "supportedProperty": [ { "@type": "SupportedProperty", @@ -70,11 +109,43 @@ "property": "", "readonly": "true", "required": "false", - "title": "name", + "title": "petId", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "quantity", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "shipDate", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "status", + "writeonly": "true" + }, + { + "@type": "SupportedProperty", + "property": "", + "readonly": "true", + "required": "false", + "title": "complete", "writeonly": "true" } ], - "title": "Category" + "title": "Order" }, { "@id": "vocab:User", @@ -93,6 +164,40 @@ ], "returns": "null", "title": "Create user" + }, + { + "@type": "http://schema.org/FindAction", + "expects": "", + "method": "GET", + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid username supplied", + "statusCode": 400 + }, + { + "description": "User not found", + "statusCode": 404 + } + ], + "returns": "vocab:User", + "title": "Get user by user name" + }, + { + "@type": "http://schema.org/AddAction", + "expects": "vocab:User", + "method": "PUT", + "possibleStatus": [ + { + "description": "Invalid user supplied", + "statusCode": 400 + } + ], + "returns": "null", + "title": "Updated user" } ], "supportedProperty": [ @@ -180,6 +285,32 @@ ], "returns": "null", "title": "Add a new pet to the store" + }, + { + "@type": "http://schema.org/AddAction", + "expects": "vocab:Pet", + "method": "PUT", + "possibleStatus": [ + { + "description": "Invalid ID supplied", + "statusCode": 400 + } + ], + "returns": "null", + "title": "Update an existing pet" + }, + { + "@type": "http://schema.org/FindAction", + "expects": "", + "method": "GET", + "possibleStatus": [ + { + "description": "successful operation", + "statusCode": 200 + } + ], + "returns": "vocab:Pet", + "title": "get all pets" } ], "supportedProperty": [ @@ -193,7 +324,7 @@ }, { "@type": "SupportedProperty", - "property": "vocab:category", + "property": "", "readonly": "true", "required": "false", "title": "category", @@ -235,26 +366,22 @@ "title": "Pet" }, { - "@id": "vocab:Order", + "@id": "vocab:ApiResponse", "@type": "hydra:Class", - "description": "this is def", + "description": "ApiResponse", "supportedOperation": [ { "@type": "http://schema.org/UpdateAction", - "expects": "vocab:Order", + "expects": "", "method": "POST", "possibleStatus": [ { "description": "successful operation", "statusCode": 200 - }, - { - "description": "Invalid Order", - "statusCode": 400 } ], - "returns": "vocab:Order", - "title": "Place an order for a pet" + "returns": "vocab:ApiResponse", + "title": "uploads an image" } ], "supportedProperty": [ @@ -263,7 +390,7 @@ "property": "", "readonly": "true", "required": "false", - "title": "id", + "title": "code", "writeonly": "true" }, { @@ -271,7 +398,7 @@ "property": "", "readonly": "true", "required": "false", - "title": "petId", + "title": "type", "writeonly": "true" }, { @@ -279,35 +406,11 @@ "property": "", "readonly": "true", "required": "false", - "title": "quantity", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "", - "readonly": "true", - "required": "false", - "title": "shipDate", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "", - "readonly": "true", - "required": "false", - "title": "status", - "writeonly": "true" - }, - { - "@type": "SupportedProperty", - "property": "", - "readonly": "true", - "required": "false", - "title": "complete", + "title": "message", "writeonly": "true" } ], - "title": "Order" + "title": "ApiResponse" }, { "@id": "http://www.w3.org/ns/hydra/core#Collection", @@ -420,49 +523,6 @@ ], "title": "PetCollection" }, - { - "@id": "vocab:OrderCollection", - "@type": "hydra:Class", - "description": "A collection of order", - "subClassOf": "http://www.w3.org/ns/hydra/core#Collection", - "supportedOperation": [ - { - "@id": "_:order_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", - "expects": "null", - "method": "GET", - "returns": "vocab:OrderCollection", - "statusCodes": [] - }, - { - "@id": "_:order_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", - "method": "PUT", - "returns": "vocab:Order", - "statusCodes": [ - { - "description": "If the Order entity was created successfully.", - "statusCode": 201 - } - ] - } - ], - "supportedProperty": [ - { - "@type": "SupportedProperty", - "description": "The order", - "property": "http://www.w3.org/ns/hydra/core#member", - "readonly": "false", - "required": "false", - "title": "members", - "writeonly": "false" - } - ], - "title": "OrderCollection" - }, { "@id": "vocab:EntryPoint", "@type": "hydra:Class", @@ -480,16 +540,91 @@ ], "supportedProperty": [ { - "hydra:description": "The Category Class", - "hydra:title": "category", + "hydra:description": "The Order Class", + "hydra:title": "order", "property": { - "@id": "vocab:EntryPoint/Category", + "@id": "vocab:EntryPoint//store/order", "@type": "hydra:Link", - "description": "Category", + "description": "this is def", "domain": "vocab:EntryPoint", - "label": "Category", - "range": "vocab:Category", - "supportedOperation": [] + "label": "Order", + "range": "vocab:Order", + "supportedOperation": [ + { + "@id": "place an order for a pet", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "vocab:Order", + "label": "Place an order for a pet", + "method": "POST", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid Order", + "statusCode": 400 + } + ] + }, + { + "@id": "find purchase order by id", + "@type": "http://schema.org/FindAction", + "description": "null", + "expects": "", + "label": "Find purchase order by ID", + "method": "GET", + "returns": "vocab:Order", + "statusCodes": [ + { + "description": "successful operation", + "statusCode": 200 + }, + { + "description": "Invalid ID supplied", + "statusCode": 400 + }, + { + "description": "Order not found", + "statusCode": 404 + } + ] + } + ] + }, + "readonly": "true", + "required": "null", + "writeonly": "false" + }, + { + "hydra:description": "The ApiResponse Class", + "hydra:title": "apiresponse", + "property": { + "@id": "vocab:EntryPoint//pet/uploadImage", + "@type": "hydra:Link", + "description": "ApiResponse", + "domain": "vocab:EntryPoint", + "label": "ApiResponse", + "range": "vocab:ApiResponse", + "supportedOperation": [ + { + "@id": "uploads an image", + "@type": "http://schema.org/UpdateAction", + "description": "null", + "expects": "", + "label": "uploads an image", + "method": "POST", + "returns": "vocab:ApiResponse", + "statusCodes": [ + { + "description": "successful operation", + "statusCode": 200 + } + ] + } + ] }, "readonly": "true", "required": "null", @@ -574,46 +709,6 @@ "readonly": "true", "required": "null", "writeonly": "false" - }, - { - "hydra:description": "The OrderCollection collection", - "hydra:title": "ordercollection", - "property": { - "@id": "vocab:EntryPoint//store/order", - "@type": "hydra:Link", - "description": "The OrderCollection collection", - "domain": "vocab:EntryPoint", - "label": "OrderCollection", - "range": "vocab:OrderCollection", - "supportedOperation": [ - { - "@id": "_:order_collection_retrieve", - "@type": "http://schema.org/FindAction", - "description": "Retrieves all Order entities", - "expects": "null", - "method": "GET", - "returns": "vocab:OrderCollection", - "statusCodes": [] - }, - { - "@id": "_:order_create", - "@type": "http://schema.org/AddAction", - "description": "Create new Order entitity", - "expects": "vocab:Order", - "method": "PUT", - "returns": "vocab:Order", - "statusCodes": [ - { - "description": "If the Order entity was created successfully.", - "statusCode": 201 - } - ] - } - ] - }, - "readonly": "true", - "required": "null", - "writeonly": "false" } ], "title": "EntryPoint" From 80e45611a86e5a9651b53b9f6c75753303012e05 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Wed, 8 Aug 2018 17:41:46 +0530 Subject: [PATCH 48/64] added give_non_collection --- test_crud_general.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test_crud_general.py b/test_crud_general.py index 493067e..2581f87 100644 --- a/test_crud_general.py +++ b/test_crud_general.py @@ -12,6 +12,7 @@ import random from typing import List import string +import sys def gen_dummy_object(class_, doc): @@ -29,7 +30,14 @@ def gen_dummy_object(class_, doc): string.ascii_uppercase + string.digits) for _ in range(6)) return object_ - +def give_non_collection(parsed_classes)->str: + for class_ in parsed_classes: + if not parsed_classes[class_]["collection"]: + print(class_) + return "ApiResponse" + #return "/pet/uploadImage" + print("No collection present exiting ...") + sys.exit() class TestCRUD(unittest.TestCase): """Test class for CRUD Tests.""" @@ -50,7 +58,8 @@ def setUpClass(self): self.doc = doc_maker.create_doc( api, self.HYDRUS_SERVER_URL, self.API_NAME) test_classes = doc_parse.get_classes(api) - self.test_class = test_classes[0]["title"] + #self.test_class = test_classes[0]["title"] + self.test_class = give_non_collection(self.doc.parsed_classes) test_properties = doc_parse.get_all_properties(test_classes) doc_parse.insert_classes(test_classes, self.session) doc_parse.insert_properties(test_properties, self.session) From b24df7b9415763c52bbe72487d3c629f334ddf22 Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Thu, 9 Aug 2018 21:35:15 +0530 Subject: [PATCH 49/64] Generalised crud tests done --- test_crud_general.py | 252 ------------------------------------------- 1 file changed, 252 deletions(-) delete mode 100644 test_crud_general.py diff --git a/test_crud_general.py b/test_crud_general.py deleted file mode 100644 index 2581f87..0000000 --- a/test_crud_general.py +++ /dev/null @@ -1,252 +0,0 @@ -"""Unit tests for CRUD operations in hydrus.data.crud.""" - -import unittest - -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker, scoped_session -import hydrus.data.crud as crud -from hydrus.data.db_models import Base -from hydrus.data import doc_parse -from hydrus.hydraspec import doc_maker -from hydrus.samples.hydra_doc_sample import doc as api -import random -from typing import List -import string -import sys - - -def gen_dummy_object(class_, doc): - """Create a dummy object based on the definitions in the API Doc.""" - object_ = { - "@type": class_ - } - if class_ in doc.parsed_classes: - for prop in doc.parsed_classes[class_]["class"].supportedProperty: - if "vocab:" in prop.prop: - prop_class = prop.prop.replace("vocab:", "") - object_[prop.title] = gen_dummy_object(prop_class, doc) - else: - object_[prop.title] = ''.join(random.choice( - string.ascii_uppercase + string.digits) for _ in range(6)) - return object_ - -def give_non_collection(parsed_classes)->str: - for class_ in parsed_classes: - if not parsed_classes[class_]["collection"]: - print(class_) - return "ApiResponse" - #return "/pet/uploadImage" - print("No collection present exiting ...") - sys.exit() -class TestCRUD(unittest.TestCase): - """Test class for CRUD Tests.""" - - @classmethod - def setUpClass(self): - """Database setup before the CRUD tests.""" - print("Creating a temporary datatbsse...") - engine = create_engine('sqlite:///:memory:') - Base.metadata.create_all(engine) - session = scoped_session(sessionmaker(bind=engine)) - id_list = api["@id"].split('/') - id_list.pop() - id_list.pop() - host = '/'.join(id_list)[0:] - self.HYDRUS_SERVER_URL = host+'/' - self.API_NAME = api["@id"].split('/')[len(api["@id"].split('/')) - 2] + '/' - self.session = session - self.doc = doc_maker.create_doc( - api, self.HYDRUS_SERVER_URL, self.API_NAME) - test_classes = doc_parse.get_classes(api) - #self.test_class = test_classes[0]["title"] - self.test_class = give_non_collection(self.doc.parsed_classes) - test_properties = doc_parse.get_all_properties(test_classes) - doc_parse.insert_classes(test_classes, self.session) - doc_parse.insert_properties(test_properties, self.session) - print("Classes and properties added successfully.") - print("Setup done, running tests...") - - def test_insert(self): - """Test CRUD insert.""" - object_ = gen_dummy_object(self.test_class, self.doc) - response = crud.insert(object_=object_, id_="1", session=self.session) - assert isinstance(response, str) - - def test_get(self): - """Test CRUD get.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = "2" - response = crud.insert(object_=object_, id_=id_, session=self.session) - object_ = crud.get(id_=id_, type_=object_[ - "@type"], session=self.session, api_name="api") - assert isinstance(response, str) - assert object_["@id"].split("/")[-1] == id_ - - def test_update(self): - """Test CRUD update.""" - object_ = gen_dummy_object(self.test_class, self.doc) - new_object = gen_dummy_object(self.test_class, self.doc) - id_ = "30" - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - update_response = crud.update( - id_=id_, - type_=object_["@type"], - object_=new_object, - session=self.session, - api_name="api") - test_object = crud.get(id_=id_, type_=object_[ - "@type"], session=self.session, api_name="api") - assert isinstance(insert_response, str) - assert isinstance(update_response, str) - assert insert_response == update_response - assert test_object["@id"].split("/")[-1] == id_ - - def test_delete(self): - """Test CRUD delete.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = "4" - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - delete_response = crud.delete( - id_=id_, type_=object_["@type"], session=self.session) - assert isinstance(insert_response, str) - response_code = None - try: - get_response = crud.get( - id_=id_, - type_=object_["@type"], - session=self.session, - api_name="api") - except Exception as e: - response_code, message = e.get_HTTP() - assert 404 == response_code - - def test_get_id(self): - """Test CRUD get when wrong/undefined ID is given.""" - id_ = "999" - type_ = self.test_class - response_code = None - try: - get_response = crud.get( - id_=id_, type_=type_, session=self.session, api_name="api") - except Exception as e: - response_code, message = e.get_HTTP() - assert 404 == response_code - - def test_get_type(self): - """Test CRUD get when wrong/undefined class is given.""" - id_ = "1" - type_ = "otherClass" - response_code = None - try: - get_response = crud.get( - id_=id_, type_=type_, session=self.session, api_name="api") - except Exception as e: - response_code, message = e.get_HTTP() - assert 400 == response_code - - def test_delete_type(self): - """Test CRUD delete when wrong/undefined class is given.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = "50" - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - assert isinstance(insert_response, str) - assert insert_response == id_ - response_code = None - try: - delete_response = crud.delete( - id_=id_, type_="otherClass", session=self.session) - except Exception as e: - response_code, message = e.get_HTTP() - assert 400 == response_code - - def test_delete_id(self): - """Test CRUD delete when wrong/undefined ID is given.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = "6" - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - response_code = None - try: - delete_response = crud.delete( - id_=999, type_=object_["@type"], session=self.session) - except Exception as e: - response_code, message = e.get_HTTP() - assert 404 == response_code - assert isinstance(insert_response, str) - assert insert_response == id_ - - def test_insert_type(self): - """Test CRUD insert when wrong/undefined class is given.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = 7 - object_["@type"] = "otherClass" - response_code = None - try: - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - except Exception as e: - response_code, message = e.get_HTTP() - assert 400 == response_code - - def test_insert_id(self): - """Test CRUD insert when used ID is given.""" - object_ = gen_dummy_object(self.test_class, self.doc) - id_ = "1" - response_code = None - try: - insert_response = crud.insert( - object_=object_, id_=id_, session=self.session) - except Exception as e: - response_code, message = e.get_HTTP() - assert 400 == response_code - - def test_insert_ids(self): - """Test CRUD insert when multiple ID's are given """ - objects = list() - ids = "1,2,3" - for index in range(len(ids.split(','))): - object = gen_dummy_object(self.test_class, self.doc) - objects.append(object) - response_code = None - try: - insert_response = crud.insert_multiple( - objects_=objects, session=self.session, id_=ids) - except Exception as e: - response_code, message = e.get_HTTP() - assert 400 == response_code - - def test_delete_ids(self): - objects = list() - ids = "1,2,3" - for index in range(len(ids.split(','))): - object = gen_dummy_object(self.test_class, self.doc) - objects.append(object) - insert_response = crud.insert_multiple(objects_=objects, - session=self.session, id_=ids) - delete_response = crud.delete_multiple( - id_=ids, type_=objects[0]["@type"], session=self.session) - - response_code = None - id_list = ids.split(',') - try: - for index in range(len(id_list)): - get_response = crud.get( - id_=id_list[index], - type_=objects[index]["@type"], - session=self.session, - api_name="api") - except Exception as e: - response_code, message = e.get_HTTP() - assert 404 == response_code - - @classmethod - def tearDownClass(self): - """Undo the setUp steps for the Class.""" - self.session.close() - - -if __name__ == '__main__': - unittest.main() From 37f1849246f33f1d30b4e765380a6b790cc56120 Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 11 Aug 2018 23:28:34 +0530 Subject: [PATCH 50/64] added some tests --- test_parser.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test_parser.py b/test_parser.py index 7f43ffc..f29912c 100644 --- a/test_parser.py +++ b/test_parser.py @@ -47,6 +47,7 @@ def test_valid_endpoint(self): assert result is "True" assert isinstance(result, str) + def test_get_class_name(self): """Test if the class name is being extracted properly from the path """ path = "A/B/C/Pet" @@ -85,6 +86,21 @@ def test_parse(self): result = openapi_parser.parse(self.doc) assert isinstance(result, str) + def test_check_collection(self): + """Test if collections are being identified properly""" + schema_block = {'type': 'array', 'items': {'$ref': '#/definitions/Pet'}} + method = "/Pet" + result = openapi_parser.check_collection(schema_block,method) + assert isinstance(result, bool) + assert result == True + + def test_check_collection_false(self): + "Test if non collections are identified" + schema = {'$ref': '#/definitions/User'} + method = "/Pet" + result = openapi_parser.check_collection(schema, method) + assert isinstance(result, bool) + assert result == False if __name__ == '__main__': print("Starting tests ..") From 72061a49c3cfffa34ce8b466d0114e63e116474f Mon Sep 17 00:00:00 2001 From: vaibhavchellani Date: Sat, 11 Aug 2018 23:31:51 +0530 Subject: [PATCH 51/64] made pep8 compliant --- test_parser.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test_parser.py b/test_parser.py index f29912c..2b8cc5c 100644 --- a/test_parser.py +++ b/test_parser.py @@ -47,7 +47,6 @@ def test_valid_endpoint(self): assert result is "True" assert isinstance(result, str) - def test_get_class_name(self): """Test if the class name is being extracted properly from the path """ path = "A/B/C/Pet" @@ -88,11 +87,13 @@ def test_parse(self): def test_check_collection(self): """Test if collections are being identified properly""" - schema_block = {'type': 'array', 'items': {'$ref': '#/definitions/Pet'}} + schema_block = { + 'type': 'array', 'items': { + '$ref': '#/definitions/Pet'}} method = "/Pet" - result = openapi_parser.check_collection(schema_block,method) + result = openapi_parser.check_collection(schema_block, method) assert isinstance(result, bool) - assert result == True + assert result def test_check_collection_false(self): "Test if non collections are identified" @@ -102,6 +103,7 @@ def test_check_collection_false(self): assert isinstance(result, bool) assert result == False + if __name__ == '__main__': print("Starting tests ..") unittest.main() From 0769015ab19ea7fdd306c900a002f2d469c489fd Mon Sep 17 00:00:00 2001 From: Muhammad Usman Date: Sun, 18 Nov 2018 18:20:16 +0530 Subject: [PATCH 52/64] Fixed parser tests and removed relative file imports --- test_parser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test_parser.py b/test_parser.py index 2b8cc5c..aeb620c 100644 --- a/test_parser.py +++ b/test_parser.py @@ -1,4 +1,6 @@ import unittest +import os +import hydrus from hydrus.hydraspec.doc_writer import HydraClass from hydrus.parser import openapi_parser @@ -7,7 +9,8 @@ def import_doc(): print("Importing Open Api Documentation ..") - with open("../samples/petstore_openapi.yaml", 'r') as stream: + abs_path = os.path.abspath(os.path.dirname(hydrus.__file__) + "/samples/petstore_openapi.yaml") + with open(abs_path, 'r') as stream: try: return yaml.load(stream) except yaml.YAMLError as exc: @@ -83,7 +86,7 @@ def test_allow_parameter(self): def test_parse(self): """Test the hydra documentation """ result = openapi_parser.parse(self.doc) - assert isinstance(result, str) + assert isinstance(result, dict) def test_check_collection(self): """Test if collections are being identified properly""" From aece1f73cd3ff4820a97983bc93a5cb167208f81 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 31 Dec 2018 05:54:43 +0530 Subject: [PATCH 53/64] Generic Refactoring to utilise str.format() Refactored the codebase to exchange string concatenation with str.format() expressions. Also changed old formatting expressions using "%s" with the same. Have not done the same with special cases including hex numbers or in the case of hydrus/hydraspec/legacy files. --- test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_parser.py b/test_parser.py index aeb620c..2fc3636 100644 --- a/test_parser.py +++ b/test_parser.py @@ -9,7 +9,7 @@ def import_doc(): print("Importing Open Api Documentation ..") - abs_path = os.path.abspath(os.path.dirname(hydrus.__file__) + "/samples/petstore_openapi.yaml") + abs_path = os.path.abspath("{}/samples/petstore_openapi.yaml".format(os.path.dirname(hydrus.__file__))) with open(abs_path, 'r') as stream: try: return yaml.load(stream) From a8fc77172f2befa4bbb2e7a0933610c914bf9f60 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Tue, 1 Jan 2019 07:43:04 +0530 Subject: [PATCH 54/64] Made code files PEP8 conformant Code files have been made PEP8 conformant by the use of autopep8 code formatter tool. This is done in order to facilitate future use and in check with standard code styles i.e. PEP8. --- test_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_parser.py b/test_parser.py index 2fc3636..c9620f5 100644 --- a/test_parser.py +++ b/test_parser.py @@ -9,7 +9,8 @@ def import_doc(): print("Importing Open Api Documentation ..") - abs_path = os.path.abspath("{}/samples/petstore_openapi.yaml".format(os.path.dirname(hydrus.__file__))) + abs_path = os.path.abspath( + "{}/samples/petstore_openapi.yaml".format(os.path.dirname(hydrus.__file__))) with open(abs_path, 'r') as stream: try: return yaml.load(stream) From 62875d6a7767a9b23dbf2b3c6db0f5fb8d32d4c5 Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Tue, 1 Jan 2019 14:51:38 +0530 Subject: [PATCH 55/64] Fix test_pep8.py, made all code PEP8 compliant. --- ...ter.py.d232acdff5bf6add5d41cf1ed0134729.py | 151 ++++++++++++++++++ test_parser.py | 5 +- 2 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py diff --git a/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py b/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py new file mode 100644 index 0000000..06bf8ec --- /dev/null +++ b/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py @@ -0,0 +1,151 @@ +import unittest +from hydrus.hydraspec import doc_writer +from unittest.mock import MagicMock, patch + + +class TestDocWriter(unittest.TestCase): + + # test context class methods + def test_context_with_nothing(self): + """ + Test method to test if correct context is generated when no arguments are passed + + """ + context = doc_writer.Context('https://hydrus.com/api') + expected_context = { + "hydra": "http://www.w3.org/ns/hydra/core#", + "property": { + "@type": "@id", + "@id": "hydra:property" + }, + "supportedClass": "hydra:supportedClass", + "supportedProperty": "hydra:supportedProperty", + "supportedOperation": "hydra:supportedOperation", + "statusCodes": "hydra:statusCodes", + "label": "rdfs:label", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "vocab": "https://hydrus.com/api/vocab#", + # "vocab": "localhost/api/vocab#", + "domain": { + "@type": "@id", + "@id": "rdfs:domain" + }, + "ApiDocumentation": "hydra:ApiDocumentation", + "range": { + "@type": "@id", + "@id": "rdfs:range" + }, + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "title": "hydra:title", + "expects": { + "@type": "@id", + "@id": "hydra:expects" + }, + "returns": { + "@id": "hydra:returns", + "@type": "@id" + }, + "readonly": "hydra:readonly", + "writeonly": "hydra:writeonly", + "possibleStatus": "hydra:possibleStatus", + "required": "hydra:required", + "method": "hydra:method", + "statusCode": "hydra:statusCode", + "description": "hydra:description", + "subClassOf": { + "@id": "rdfs:subClassOf", + "@type": "@id" + } + } + self.assertEqual(expected_context, context.generate()) + + @patch('hydrus.hydraspec.doc_writer.HydraEntryPoint', spec=doc_writer.HydraEntryPoint) + def test_context_with_entrypoint(self, mock_entry): + """ + Test method to test if correct context is generated when HydraEntryPoint is passed + + """ + + hydra_entry_point_mock = mock_entry() + hydra_entry_point_mock.base_url = "http://petstore.swagger.io/v2" + hydra_entry_point_mock.entrypoint = "EntryPoint" + + context = doc_writer.Context('http://petstore.swagger.io/v2', + entrypoint=hydra_entry_point_mock) + + expected_context = { + "EntryPoint": "vocab:EntryPoint", + "vocab": "http://petstore.swagger.io/v2/vocab#" + } + self.assertEqual(expected_context, context.generate()) + + def test_context_with_class(self): + """ + Test method to test if correct context is generated when HydraClass is passed + + """ + + mocked_hydra_class = MagicMock() + with patch( + 'hydrus.hydraspec.doc_writer.HydraClass', + mocked_hydra_class, spec_set=doc_writer.HydraClass): + mocked_hydra_property = MagicMock() + mocked_hydra_class.id_ = "vocab:Pet" + mocked_hydra_class.title = "Pet" + mocked_hydra_class.desc = "Pet" + with patch('hydrus.hydraspec.doc_writer.HydraClassProp', mocked_hydra_property, + spec_set=doc_writer.HydraClassProp): + mocked_hydra_property.prop = "" + mocked_hydra_property.readonly = "true" + mocked_hydra_property.required = "false" + mocked_hydra_property.title = "id" + mocked_hydra_property.writeonly = "true" + + mocked_hydra_class.supportedProperty = [mocked_hydra_property] + + context = doc_writer.Context( + 'http://petstore.swagger.io/v2', + class_=mocked_hydra_class) + + expected_context = { + "vocab": "http://petstore.swagger.io/v2/vocab#", + "hydra": "http://www.w3.org/ns/hydra/core#", + "members": "http://www.w3.org/ns/hydra/core#member", + "object": "http://schema.org/object", + "Pet": "vocab:Pet", + "id": "" + } + + self.assertEqual(expected_context, context.generate()) + + @patch('hydrus.hydraspec.doc_writer.HydraClass', spec=doc_writer.HydraClass) + @patch('hydrus.hydraspec.doc_writer.HydraCollection', spec=doc_writer.HydraCollection) + def test_context_with_collection(self, hydra_class, hydra_collection): + """ + Test method to test if correct context is generated when HydraCollection is passed + + """ + mocked_hydra_class = hydra_class() + mocked_hydra_class.id_ = "vocab:Pet" + mocked_hydra_class.title = "Pet" + mocked_hydra_class.desc = "Pet" + + mocked_hydra_collection = hydra_collection() + mocked_hydra_collection.class_ = mocked_hydra_class + mocked_hydra_collection.name = mocked_hydra_class.title + "Collection" + + context = doc_writer.Context( + 'http://petstore.swagger.io/v2', + collection=mocked_hydra_collection) + expected_context = { + "vocab": "http://petstore.swagger.io/v2/vocab#", + "hydra": "http://www.w3.org/ns/hydra/core#", + "members": "http://www.w3.org/ns/hydra/core#member", + "PetCollection": "vocab:PetCollection", + "Pet": "vocab:Pet" + } + + self.assertEqual(expected_context, context.generate()) + + if __name__ == '__main__': + unittest.main() diff --git a/test_parser.py b/test_parser.py index aeb620c..5d39563 100644 --- a/test_parser.py +++ b/test_parser.py @@ -9,7 +9,8 @@ def import_doc(): print("Importing Open Api Documentation ..") - abs_path = os.path.abspath(os.path.dirname(hydrus.__file__) + "/samples/petstore_openapi.yaml") + abs_path = os.path.abspath(os.path.dirname( + hydrus.__file__) + "/samples/petstore_openapi.yaml") with open(abs_path, 'r') as stream: try: return yaml.load(stream) @@ -104,7 +105,7 @@ def test_check_collection_false(self): method = "/Pet" result = openapi_parser.check_collection(schema, method) assert isinstance(result, bool) - assert result == False + assert not result if __name__ == '__main__': From 73ad2d672a5a2fb55a815316d9a356fdf9f25428 Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Tue, 1 Jan 2019 15:00:55 +0530 Subject: [PATCH 56/64] Add PEP8 changes missed in previous commit --- hydra_doc_sample.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hydra_doc_sample.py b/hydra_doc_sample.py index 95d4b09..8ce592a 100644 --- a/hydra_doc_sample.py +++ b/hydra_doc_sample.py @@ -48,7 +48,12 @@ }, "@id": "http://petstore.swagger.io/v2/vocab", "@type": "ApiDocumentation", - "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.", + "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.", "possibleStatus": [], "supportedClass": [ { From 1226dad5572c32d96003a8b6686442a34e3db2ea Mon Sep 17 00:00:00 2001 From: Akshay Dahiya Date: Tue, 1 Jan 2019 17:35:42 +0530 Subject: [PATCH 57/64] Delete test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py --- ...ter.py.d232acdff5bf6add5d41cf1ed0134729.py | 151 ------------------ 1 file changed, 151 deletions(-) delete mode 100644 test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py diff --git a/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py b/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py deleted file mode 100644 index 06bf8ec..0000000 --- a/test_doc_writer.py.d232acdff5bf6add5d41cf1ed0134729.py +++ /dev/null @@ -1,151 +0,0 @@ -import unittest -from hydrus.hydraspec import doc_writer -from unittest.mock import MagicMock, patch - - -class TestDocWriter(unittest.TestCase): - - # test context class methods - def test_context_with_nothing(self): - """ - Test method to test if correct context is generated when no arguments are passed - - """ - context = doc_writer.Context('https://hydrus.com/api') - expected_context = { - "hydra": "http://www.w3.org/ns/hydra/core#", - "property": { - "@type": "@id", - "@id": "hydra:property" - }, - "supportedClass": "hydra:supportedClass", - "supportedProperty": "hydra:supportedProperty", - "supportedOperation": "hydra:supportedOperation", - "statusCodes": "hydra:statusCodes", - "label": "rdfs:label", - "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - "vocab": "https://hydrus.com/api/vocab#", - # "vocab": "localhost/api/vocab#", - "domain": { - "@type": "@id", - "@id": "rdfs:domain" - }, - "ApiDocumentation": "hydra:ApiDocumentation", - "range": { - "@type": "@id", - "@id": "rdfs:range" - }, - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - "title": "hydra:title", - "expects": { - "@type": "@id", - "@id": "hydra:expects" - }, - "returns": { - "@id": "hydra:returns", - "@type": "@id" - }, - "readonly": "hydra:readonly", - "writeonly": "hydra:writeonly", - "possibleStatus": "hydra:possibleStatus", - "required": "hydra:required", - "method": "hydra:method", - "statusCode": "hydra:statusCode", - "description": "hydra:description", - "subClassOf": { - "@id": "rdfs:subClassOf", - "@type": "@id" - } - } - self.assertEqual(expected_context, context.generate()) - - @patch('hydrus.hydraspec.doc_writer.HydraEntryPoint', spec=doc_writer.HydraEntryPoint) - def test_context_with_entrypoint(self, mock_entry): - """ - Test method to test if correct context is generated when HydraEntryPoint is passed - - """ - - hydra_entry_point_mock = mock_entry() - hydra_entry_point_mock.base_url = "http://petstore.swagger.io/v2" - hydra_entry_point_mock.entrypoint = "EntryPoint" - - context = doc_writer.Context('http://petstore.swagger.io/v2', - entrypoint=hydra_entry_point_mock) - - expected_context = { - "EntryPoint": "vocab:EntryPoint", - "vocab": "http://petstore.swagger.io/v2/vocab#" - } - self.assertEqual(expected_context, context.generate()) - - def test_context_with_class(self): - """ - Test method to test if correct context is generated when HydraClass is passed - - """ - - mocked_hydra_class = MagicMock() - with patch( - 'hydrus.hydraspec.doc_writer.HydraClass', - mocked_hydra_class, spec_set=doc_writer.HydraClass): - mocked_hydra_property = MagicMock() - mocked_hydra_class.id_ = "vocab:Pet" - mocked_hydra_class.title = "Pet" - mocked_hydra_class.desc = "Pet" - with patch('hydrus.hydraspec.doc_writer.HydraClassProp', mocked_hydra_property, - spec_set=doc_writer.HydraClassProp): - mocked_hydra_property.prop = "" - mocked_hydra_property.readonly = "true" - mocked_hydra_property.required = "false" - mocked_hydra_property.title = "id" - mocked_hydra_property.writeonly = "true" - - mocked_hydra_class.supportedProperty = [mocked_hydra_property] - - context = doc_writer.Context( - 'http://petstore.swagger.io/v2', - class_=mocked_hydra_class) - - expected_context = { - "vocab": "http://petstore.swagger.io/v2/vocab#", - "hydra": "http://www.w3.org/ns/hydra/core#", - "members": "http://www.w3.org/ns/hydra/core#member", - "object": "http://schema.org/object", - "Pet": "vocab:Pet", - "id": "" - } - - self.assertEqual(expected_context, context.generate()) - - @patch('hydrus.hydraspec.doc_writer.HydraClass', spec=doc_writer.HydraClass) - @patch('hydrus.hydraspec.doc_writer.HydraCollection', spec=doc_writer.HydraCollection) - def test_context_with_collection(self, hydra_class, hydra_collection): - """ - Test method to test if correct context is generated when HydraCollection is passed - - """ - mocked_hydra_class = hydra_class() - mocked_hydra_class.id_ = "vocab:Pet" - mocked_hydra_class.title = "Pet" - mocked_hydra_class.desc = "Pet" - - mocked_hydra_collection = hydra_collection() - mocked_hydra_collection.class_ = mocked_hydra_class - mocked_hydra_collection.name = mocked_hydra_class.title + "Collection" - - context = doc_writer.Context( - 'http://petstore.swagger.io/v2', - collection=mocked_hydra_collection) - expected_context = { - "vocab": "http://petstore.swagger.io/v2/vocab#", - "hydra": "http://www.w3.org/ns/hydra/core#", - "members": "http://www.w3.org/ns/hydra/core#member", - "PetCollection": "vocab:PetCollection", - "Pet": "vocab:Pet" - } - - self.assertEqual(expected_context, context.generate()) - - if __name__ == '__main__': - unittest.main() From b0151db55ab4accb8e105edfef642a8d50523c10 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 8 Jan 2019 18:05:44 +0000 Subject: [PATCH 58/64] Initial commit --- .gitignore | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++ README.md | 1 + 3 files changed, 126 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..894a44c --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0d1d964 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 W3C Hydra + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f76a931 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# hydra-openapi-parser \ No newline at end of file From 516e6f878287516e1059b8db4662f1e64e358aa3 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 21 Jan 2019 00:07:34 +0530 Subject: [PATCH 59/64] Move openapi parser with history into new repo Move contents of openapi parser into a new repo for maintainance purposes. --- __init__.py => hydra-openapi-parser/__init__.py | 0 openapi_parser.py => hydra-openapi-parser/openapi_parser.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename __init__.py => hydra-openapi-parser/__init__.py (100%) rename openapi_parser.py => hydra-openapi-parser/openapi_parser.py (100%) diff --git a/__init__.py b/hydra-openapi-parser/__init__.py similarity index 100% rename from __init__.py rename to hydra-openapi-parser/__init__.py diff --git a/openapi_parser.py b/hydra-openapi-parser/openapi_parser.py similarity index 100% rename from openapi_parser.py rename to hydra-openapi-parser/openapi_parser.py From 42f7239d4f76116716d45e154820f232d2e6df8f Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 21 Jan 2019 00:41:37 +0530 Subject: [PATCH 60/64] Move tests related to parser into new repo --- __init__.py => hydra-openapi-parser/tests/__init__.py | 0 test_parser.py => hydra-openapi-parser/tests/test_parser.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename __init__.py => hydra-openapi-parser/tests/__init__.py (100%) rename test_parser.py => hydra-openapi-parser/tests/test_parser.py (100%) diff --git a/__init__.py b/hydra-openapi-parser/tests/__init__.py similarity index 100% rename from __init__.py rename to hydra-openapi-parser/tests/__init__.py diff --git a/test_parser.py b/hydra-openapi-parser/tests/test_parser.py similarity index 100% rename from test_parser.py rename to hydra-openapi-parser/tests/test_parser.py From ca2115f805e413ede0e277e083f77db48ec81e69 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 21 Jan 2019 01:04:05 +0530 Subject: [PATCH 61/64] Correct files to reflect moving code from one repo to another Make changes to openapi_parser.py and it's test program to reflect move from one repo to another --- hydra-openapi-parser/openapi_parser.py | 2 +- hydra-openapi-parser/tests/test_parser.py | 4 ++-- requirements.txt | 1 + setup.py | 29 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/hydra-openapi-parser/openapi_parser.py b/hydra-openapi-parser/openapi_parser.py index 29b5b16..daed915 100644 --- a/hydra-openapi-parser/openapi_parser.py +++ b/hydra-openapi-parser/openapi_parser.py @@ -5,7 +5,7 @@ import yaml import json from typing import Any, Dict, Match, Optional, Tuple, Union, List, Set -from hydrus.hydraspec.doc_writer import (HydraDoc, HydraClass, +from hydra_python_core.doc_writer import (HydraDoc, HydraClass, HydraClassProp, HydraClassOp) import sys diff --git a/hydra-openapi-parser/tests/test_parser.py b/hydra-openapi-parser/tests/test_parser.py index fe3c888..681a61a 100644 --- a/hydra-openapi-parser/tests/test_parser.py +++ b/hydra-openapi-parser/tests/test_parser.py @@ -2,8 +2,8 @@ import os import hydrus -from hydrus.hydraspec.doc_writer import HydraClass -from hydrus.parser import openapi_parser +from hydra_python_core.doc_writer import HydraClass +from hydra_openapi_parser import openapi_parser import yaml diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6151171 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +PyYAML==4.2b1 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..97317e5 --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +"""Setup script for Hydra's OpenAPI Parser.""" + +from setuptools import setup, find_packages + +try: # for pip >= 10 + from pip._internal.req import parse_requirements + from pip._internal.download import PipSession +except ImportError: # for pip <= 9.0.3 + from pip.req import parse_requirements + from pip.download import PipSession + + +install_requires = parse_requirements('requirements.txt', session=PipSession()) +dependencies = [str(package.req) for package in install_requires] + +setup(name='hydra-openapi-parser', + include_package_data=True, + version='0.0.1', + description='An OpenAPI parser for W3C HYDRA Draft', + author='W3C HYDRA development group', + author_email='public-hydra@w3.org', + url='https://github.com/HTTP-APIs/hydra-openapi-parser', + python_requires='>=3', + install_requires=dependencies, + packages=find_packages( + exclude=['build', 'dist', 'hydra_openapi_parser.egg-info']), + package_dir={'hydra_openapi_parser': + 'hydra_openapi_parser'}, + ) \ No newline at end of file From a655a4640c439632c7779e2eaa50eb3b063fc1ee Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 21 Jan 2019 01:25:16 +0530 Subject: [PATCH 62/64] Copying samples into hydra-openapi-parser repo --- __init__.py => hydra-openapi-parser/samples/__init__.py | 0 .../samples/hydra_doc_sample.py | 0 .../samples/petstore_openapi.yaml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename __init__.py => hydra-openapi-parser/samples/__init__.py (100%) rename hydra_doc_sample.py => hydra-openapi-parser/samples/hydra_doc_sample.py (100%) rename petstore_openapi.yaml => hydra-openapi-parser/samples/petstore_openapi.yaml (100%) diff --git a/__init__.py b/hydra-openapi-parser/samples/__init__.py similarity index 100% rename from __init__.py rename to hydra-openapi-parser/samples/__init__.py diff --git a/hydra_doc_sample.py b/hydra-openapi-parser/samples/hydra_doc_sample.py similarity index 100% rename from hydra_doc_sample.py rename to hydra-openapi-parser/samples/hydra_doc_sample.py diff --git a/petstore_openapi.yaml b/hydra-openapi-parser/samples/petstore_openapi.yaml similarity index 100% rename from petstore_openapi.yaml rename to hydra-openapi-parser/samples/petstore_openapi.yaml From 05354544f83e84832d646cd97946afcbff8bf46c Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Mon, 21 Jan 2019 22:32:28 +0530 Subject: [PATCH 63/64] Make changes to get the tests to work Point the test files to the files within parent directory of the tests to solve the issue with os.path. This must be tested on non unix OSes --- README.md | 8 +++++++- hydra-openapi-parser/tests/test_parser.py | 3 +-- setup.py | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f76a931..83beaba 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# hydra-openapi-parser \ No newline at end of file +# hydra-openapi-parser + +How to work with this project +``` +pip install -e git+git://github.com/HTTP-APIs/hydra-python-core#egg=hydra-python-core +pip install -e . +``` \ No newline at end of file diff --git a/hydra-openapi-parser/tests/test_parser.py b/hydra-openapi-parser/tests/test_parser.py index 681a61a..a26e76d 100644 --- a/hydra-openapi-parser/tests/test_parser.py +++ b/hydra-openapi-parser/tests/test_parser.py @@ -9,8 +9,7 @@ def import_doc(): print("Importing Open Api Documentation ..") - abs_path = os.path.abspath("{}/samples/petstore_openapi.yaml".format(os.path.dirname( - hydrus.__file__))) + abs_path = os.path.abspath("{}/../samples/petstore_openapi.yaml".format(os.path.dirname(__file__))) with open(abs_path, 'r') as stream: try: return yaml.load(stream) diff --git a/setup.py b/setup.py index 97317e5..3909fec 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,5 @@ install_requires=dependencies, packages=find_packages( exclude=['build', 'dist', 'hydra_openapi_parser.egg-info']), - package_dir={'hydra_openapi_parser': - 'hydra_openapi_parser'}, + package_dir={'hydra-openapi-parser':'hydra-openapi-parser'}, ) \ No newline at end of file From 45522b35a0a13f98ddeba73fd5056ff69abd30dc Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 24 Jan 2019 01:59:48 +0530 Subject: [PATCH 64/64] Rename the folder to maintain structure --- {hydra-openapi-parser => openapi_parser}/__init__.py | 0 {hydra-openapi-parser => openapi_parser}/openapi_parser.py | 0 {hydra-openapi-parser => openapi_parser}/samples/__init__.py | 0 .../samples/hydra_doc_sample.py | 0 .../samples/petstore_openapi.yaml | 0 {hydra-openapi-parser => openapi_parser}/tests/__init__.py | 0 {hydra-openapi-parser => openapi_parser}/tests/test_parser.py | 2 +- 7 files changed, 1 insertion(+), 1 deletion(-) rename {hydra-openapi-parser => openapi_parser}/__init__.py (100%) rename {hydra-openapi-parser => openapi_parser}/openapi_parser.py (100%) rename {hydra-openapi-parser => openapi_parser}/samples/__init__.py (100%) rename {hydra-openapi-parser => openapi_parser}/samples/hydra_doc_sample.py (100%) rename {hydra-openapi-parser => openapi_parser}/samples/petstore_openapi.yaml (100%) rename {hydra-openapi-parser => openapi_parser}/tests/__init__.py (100%) rename {hydra-openapi-parser => openapi_parser}/tests/test_parser.py (97%) diff --git a/hydra-openapi-parser/__init__.py b/openapi_parser/__init__.py similarity index 100% rename from hydra-openapi-parser/__init__.py rename to openapi_parser/__init__.py diff --git a/hydra-openapi-parser/openapi_parser.py b/openapi_parser/openapi_parser.py similarity index 100% rename from hydra-openapi-parser/openapi_parser.py rename to openapi_parser/openapi_parser.py diff --git a/hydra-openapi-parser/samples/__init__.py b/openapi_parser/samples/__init__.py similarity index 100% rename from hydra-openapi-parser/samples/__init__.py rename to openapi_parser/samples/__init__.py diff --git a/hydra-openapi-parser/samples/hydra_doc_sample.py b/openapi_parser/samples/hydra_doc_sample.py similarity index 100% rename from hydra-openapi-parser/samples/hydra_doc_sample.py rename to openapi_parser/samples/hydra_doc_sample.py diff --git a/hydra-openapi-parser/samples/petstore_openapi.yaml b/openapi_parser/samples/petstore_openapi.yaml similarity index 100% rename from hydra-openapi-parser/samples/petstore_openapi.yaml rename to openapi_parser/samples/petstore_openapi.yaml diff --git a/hydra-openapi-parser/tests/__init__.py b/openapi_parser/tests/__init__.py similarity index 100% rename from hydra-openapi-parser/tests/__init__.py rename to openapi_parser/tests/__init__.py diff --git a/hydra-openapi-parser/tests/test_parser.py b/openapi_parser/tests/test_parser.py similarity index 97% rename from hydra-openapi-parser/tests/test_parser.py rename to openapi_parser/tests/test_parser.py index a26e76d..312f21a 100644 --- a/hydra-openapi-parser/tests/test_parser.py +++ b/openapi_parser/tests/test_parser.py @@ -9,7 +9,7 @@ def import_doc(): print("Importing Open Api Documentation ..") - abs_path = os.path.abspath("{}/../samples/petstore_openapi.yaml".format(os.path.dirname(__file__))) + abs_path = os.path.abspath("{}/samples/petstore_openapi.yaml".format(os.path.dirname(openapi_parser.__file__))) with open(abs_path, 'r') as stream: try: return yaml.load(stream)