Hello,
I am trying to import a swagger spec into the Developer Portal using the API, i make the following request (minimalistic petstore example as payload from OpenAPISpec ) at
And i get the following response
{ "id": "306b89d2-90e2-4818-9816-777517c11131", "revisionNumber": 7, "baseUrl": "http://petstore.swagger.io/api", "releaseVersion": "1.0.0", "resources": [ { "id": "57da2edf-7431-4061-a124-1de4837d0936", "name": "pets", "baseUrl": "http://petstore.swagger.io/api", "path": "/pets", "parameters": [ { "dataType": "string", "name": "Content-Type", "options": [ "application/json" ], "type": "header" } ], "methods": [ { "id": "b83c49bb-6bb7-4277-b665-13ecfca6f01d", "name": "addPet", "description": "Creates a new pet in the store. Duplicates are allowed", "verb": "post", "parameters": [], "body": { "accept": "application/json", "attachments": [], "doc": "Pet to add to the store", "parameters": [ { "allowMultiple": false, "dataType": "object", "name": "pet", "required": true, "schema": "{\n \"$ref\" : \"#/definitions/NewPet\"\n}", "type": "body" } ] }, "response": { "errors": [], "parameters": [], "schema": { "dataType": "{\n \"$ref\" : \"#/definitions/Pet\"\n}{\n \"$ref\" : \"#/definitions/ErrorModel\"\n}" } }, "apiSchema": { "type": "json" }, "customAttributes": { "SWAGGER_PRODUCES": "[ \"application/json\" ]", "SWAGGER_METHOD_AUTH": "" }, "createdTime": 1471461176019, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "baseUrl": "http://petstore.swagger.io/api", "methods": [], "path": "/pets", "resourceId": "57da2edf-7431-4061-a124-1de4837d0936", "resourceName": "pets", "resources": [], "revisionNumber": 7 }, { "id": "335fc048-a729-45ab-a48c-ad4b3858aaa1", "name": "findPets", "description": "Returns all pets from the system that the user has access to", "verb": "get", "parameters": [ { "allowMultiple": false, "dataType": "array", "description": "tags to filter by", "items": "{\n \"type\" : \"string\"\n}", "name": "tags", "required": false, "type": "query" }, { "allowMultiple": false, "dataType": "integer", "description": "maximum number of results to return", "name": "limit", "required": false, "type": "query" } ], "body": { "accept": "application/json,application/xml,text/xml,text/html", "attachments": [], "parameters": [] }, "response": { "errors": [], "parameters": [], "schema": { "dataType": "{\n \"type\" : \"array\",\n \"items\" : {\n \"$ref\" : \"#/definitions/Pet\"\n }\n}{\n \"$ref\" : \"#/definitions/ErrorModel\"\n}" } }, "apiSchema": { "type": "json" }, "customAttributes": { "SWAGGER_PRODUCES": "[ \"application/json\", \"application/xml\", \"text/xml\", \"text/html\" ]", "SWAGGER_METHOD_AUTH": "" }, "createdTime": 1471461176019, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "baseUrl": "http://petstore.swagger.io/api", "methods": [], "path": "/pets", "resourceId": "57da2edf-7431-4061-a124-1de4837d0936", "resourceName": "pets", "resources": [], "revisionNumber": 7 } ], "customAttributes": { "SWAGGER_RESOURCE_PATH": "/pets", "SWAGGER_PRODUCES": "[ \"application/json\" ]", "SWAGGER_PROTOCOLS": "[ \"http\" ]" }, "createdTime": 1471461176017, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "resources": [], "revisionNumber": 7 }, { "id": "8451e805-1b7c-4dad-9f3d-3e2b79d63a54", "name": "pets-id", "baseUrl": "http://petstore.swagger.io/api", "path": "/pets/{id}", "parameters": [ { "dataType": "string", "name": "Content-Type", "options": [ "application/json" ], "type": "header" } ], "methods": [ { "id": "b3e6721f-fe3a-4973-af32-29a9a05e1c77", "name": "findPetById", "description": "Returns a user based on a single ID, if the user does not have access to the pet", "verb": "get", "parameters": [ { "allowMultiple": false, "dataType": "integer", "description": "ID of pet to fetch", "name": "id", "required": true, "type": "template" } ], "body": { "accept": "application/json,application/xml,text/xml,text/html", "attachments": [], "parameters": [] }, "response": { "errors": [], "parameters": [], "schema": { "dataType": "{\n \"$ref\" : \"#/definitions/Pet\"\n}{\n \"$ref\" : \"#/definitions/ErrorModel\"\n}" } }, "apiSchema": { "type": "json" }, "customAttributes": { "SWAGGER_PRODUCES": "[ \"application/json\", \"application/xml\", \"text/xml\", \"text/html\" ]", "SWAGGER_METHOD_AUTH": "" }, "createdTime": 1471461176019, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "baseUrl": "http://petstore.swagger.io/api", "methods": [], "path": "/pets/{id}", "resourceId": "8451e805-1b7c-4dad-9f3d-3e2b79d63a54", "resourceName": "pets-id", "resources": [], "revisionNumber": 7 }, { "id": "dff7d062-af91-47b3-8829-2cccf9c991c1", "name": "deletePet", "description": "deletes a single pet based on the ID supplied", "verb": "delete", "parameters": [ { "allowMultiple": false, "dataType": "integer", "description": "ID of pet to delete", "name": "id", "required": true, "type": "template" } ], "body": { "attachments": [], "parameters": [] }, "response": { "errors": [ { "code": "204", "description": "pet deleted", "httpStatusCode": "204" } ], "parameters": [], "schema": { "dataType": "{\n \"$ref\" : \"#/definitions/ErrorModel\"\n}" } }, "apiSchema": { "type": "json" }, "customAttributes": { "SWAGGER_METHOD_AUTH": "" }, "createdTime": 1471461176019, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "baseUrl": "http://petstore.swagger.io/api", "methods": [], "path": "/pets/{id}", "resourceId": "8451e805-1b7c-4dad-9f3d-3e2b79d63a54", "resourceName": "pets-id", "resources": [], "revisionNumber": 7 } ], "customAttributes": { "SWAGGER_RESOURCE_PATH": "/pets/{id}", "SWAGGER_PRODUCES": "[ \"application/json\" ]", "SWAGGER_PROTOCOLS": "[ \"http\" ]" }, "createdTime": 1471461176017, "apiRevisionId": "306b89d2-90e2-4818-9816-777517c11131", "resources": [], "revisionNumber": 7 } ], "customAttributes": { "SWAGGER_INFO": "{\n \"description\" : \"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification\",\n \"version\" : \"1.0.0\",\n \"title\" : \"Swagger Petstore\",\n \"termsOfService\" : \"http://swagger.io/terms/\",\n \"contact\" : {\n \"name\" : \"Swagger API Team\"\n },\n \"license\" : {\n \"name\" : \"MIT\"\n }\n}", "SWAGGER_VERSION": "2.0" }, "createdTime": 1471461175983 }
Everything seems to fine, but when i go to the UI to publish the spec, i see that the parameters are missing and the final documentation rendered is almost empty (nothing besides description for POST API's as well, no button to send request,etc.)
What am i doing wrong? Any guidance will be appreciated
Solved! Go to Solution.
@Rahul Ok After some research and help from our expert @Gitesh Koli we are able to resolve this.
You were getting this error in Rendering and publishing because there is a template that goes with this API. This template is automatically loaded when you use the dev portal UI to import the swagger file. However, this template was missing when you uploaded the swagger file through Smartdoc api.
All you need to do is upload the template as follows and it should fix your problem.
use the api call to post the template as follows:
Also, now your api sequence will be as follows:
Thanks and hope this helps.
--Pradeep