Sample Swagger 2.0 json/yaml files

6,200 views
Skip to first unread message

Shanmugam Ramasamy

unread,
Dec 9, 2014, 8:21:19 AM12/9/14
to swagger-sw...@googlegroups.com
Hi,

I am an API developer.
I'm learning Swagger 2.0 and the latest Swagger parser for Java.
Could you please share me the sample json/yaml files that are compatible with Swagger 2.0?

Thanks in Advance,
Shan.

Ron

unread,
Dec 9, 2014, 8:25:54 AM12/9/14
to swagger-sw...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Dec 9, 2014, 8:36:36 AM12/9/14
to swagger-sw...@googlegroups.com

Shan R

unread,
Dec 10, 2014, 12:50:04 AM12/10/14
to swagger-sw...@googlegroups.com
Hi Ron,

Thank you, those examples helped.
As per the swagger spec, defined in https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#file-structure, the references can be in different json files and can be linked them with $ref token [the schema for a request payload (for body parameter) & schema of response objects] )

Do you have any examples for that?

Thanks again,
Shan.

You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/VXBeLwh8l48/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.

Ron

unread,
Dec 10, 2014, 4:41:50 AM12/10/14
to swagger-sw...@googlegroups.com

Shan R

unread,
Dec 22, 2014, 3:10:53 AM12/22/14
to swagger-sw...@googlegroups.com
Hi Ron,

I tried to parse this swagger file using the swagger parser built from https://github.com/swagger-api/swagger-parser.
I could not find the exact APIs to extract the resource/operation details linked to external file via $ref as like the one you have mentioned in your previous email.
I can only able to get the operations that are defined in the same document.
I followed the com.wordnik.swagger.models.Path class to extract the operations defined on this path.
Is there any other way to look up and extract the linked resource details?

Below is my code snippet that I used in my application:

Map<String, Path> paths = swagger.getPaths();
            Set<Entry<String, Path>> entrySet = paths.entrySet();
            for (Entry<String, Path> entry : entrySet) {
                String pathId = entry.getKey();
                Path path = entry.getValue();
                System.out.println("\t Resource path : " + pathId);
               
                Operation getOperation = path.getGet();
                if (getOperation != null) {
                    System.out.println("\t \t Method Type : GET");
                    printOperationDetails(getOperation);
                }
               
                Operation postOperation = path.getPost();
                if (postOperation != null) {
                    System.out.println("\t \t Method Type : POST");
                    printOperationDetails(postOperation);
                }
               
                Operation putOperation = path.getPut();
                if (putOperation != null) {
                    System.out.println("\t \t Method Type : PUT");
                    printOperationDetails(putOperation);
                }
               
                Operation deleteOperation = path.getDelete();
                if (deleteOperation != null) {
                    System.out.println("\t \t Method Type : DELETE");
                    printOperationDetails(deleteOperation);
                }
   }

Thank you,
Shan.

Ron

unread,
Dec 23, 2014, 7:42:20 AM12/23/14
to swagger-sw...@googlegroups.com
It's quite possible the Parser does not support external $refs, especially for operations.

I would advice you to not use $ref's under the Path Item object at the moment as we have a fundamental issue with it that needs to be solved, and may change the current behavior.

Ram Kris

unread,
Jan 18, 2016, 8:16:33 AM1/18/16
to Swagger
Hi Ron,

I am new to this swagger parser. I want to write a code in java that will connect to my swagger using client certificate, and then it should validate all the responses against the swagger schemas. Would the swagger parser be an ideal ones..?

Thanks,
RK


On Tuesday, 9 December 2014 18:55:54 UTC+5:30, Ron R wrote:
On 9 December 2014 at 15:21, Shanmugam Ramasamy <avr.sh...@gmail.com> wrote:
Hi,

I am an API developer.
I'm learning Swagger 2.0 and the latest Swagger parser for Java.
Could you please share me the sample json/yaml files that are compatible with Swagger 2.0?

Thanks in Advance,
Shan.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Jan 18, 2016, 7:50:32 PM1/18/16
to swagger-sw...@googlegroups.com
Are you referring to the client or server?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Ram Kris

unread,
Jan 19, 2016, 4:53:51 AM1/19/16
to Swagger
Client
Reply all
Reply to author
Forward
0 new messages