how to write a swagger for an api which is called by its basepath and verb not resource path

Not applicable

I have a service which is called by its basepath and its verb,there is no resource path.As in swagger path is a mandatory one,so i am unable to write the corresponding swagger for it.

Scenario i Tried :-

Suppose my basepath is abc/v1/xyz, i tried writting the swagger by giving the path as / it worked but when i hit the service in dev portal or soapUI it says unknown resource ,i think because of extra /

So,how should i write a swagger for such scenario?

Any leads on this situation?please help

Thanks

Solved Solved
0 8 1,111
1 ACCEPTED SOLUTION

llynch
New Member

Hi @shubham singh,

We do have an example of this scenario working using the Apigee Mock Target API. Though, in this example, the basepath is not specified and defaults to / (indicating that all paths start with server root).

Here is the YAML: https://github.com/apigee/api-platform-samples/blob/master/default-proxies/helloworld/openapi/mockta...

Here is the resulting SmartDocs: http://docs.apigee.com/api-services/content/mock-target-api

I realize that this does not explain why your spec is not working, but I wanted to provide you with a sample that validates the scenario you describe. (The call works in SmartDocs, even with the trailing slash.) Hoping it might help with troubleshooting.

HTH,

Liz

View solution in original post

8 REPLIES 8

when you mean "hit the service in dev portal" , Are you talking about smartdocs ?

Not applicable

@Anil Sagar Yes..just importing my json swagger in my dev portal and try to hit the service which i have build

@shubham singh It is failing probably due to the trailing /. Any specific reason why you do not have a resource path, as not having a resource path is not good design

llynch
New Member

Hi @shubham singh,

We do have an example of this scenario working with the Mock Target API example. Though, in this example there is no basepath defined, so it defaults to / indicating all paths start at server root.

Here is the YAML: https://github.com/apigee/api-platform-samples/blob/master/default-proxies/helloworld/openapi/mockta...

Here is the resulting SmartDocs: http://docs.apigee.com/api-services/content/mock-target-api

That doesn't explain why your spec is not working. But I wanted to provide you with a sample that does work to validate the scenario and in case the example helps with troubleshooting.

HTH.

Liz

llynch
New Member

Hi @shubham singh,

We do have an example of this scenario working using the Apigee Mock Target API. Though, in this example, the basepath is not specified and defaults to / (indicating that all paths start with server root).

Here is the YAML: https://github.com/apigee/api-platform-samples/blob/master/default-proxies/helloworld/openapi/mockta...

Here is the resulting SmartDocs: http://docs.apigee.com/api-services/content/mock-target-api

I realize that this does not explain why your spec is not working, but I wanted to provide you with a sample that validates the scenario you describe. (The call works in SmartDocs, even with the trailing slash.) Hoping it might help with troubleshooting.

HTH,

Liz

@Liz Lynch

In the scenario which you mentioned.When there is no basepath provided its defaulting to '/' .So even from portal when triggered it works.

As Shubham mentioned,We have basepath and no resource path which will not be defaulted to '/' (is my understanding).Can you please help me here .

Hi @dhriti,

If you define your path as /, I would expect that it would use the server root and basepath as the path for that resource. But it sounds like that's not happening in your case. Would you be able to share a snippet of your spec that shows how the host, basepath, and resource are defined? Perhaps this may shed light. You can share privately to lizlynch@google.com if you prefer.

Apologies for the issues you are facing.

Liz

@Liz Lynch i have mailed you to your mentioned email id