Is there any way to retrieve all the models from Swagger API docs?

26 views
Skip to first unread message

Jose Martinez

unread,
Aug 30, 2016, 8:27:08 PM8/30/16
to Swagger
Hi there,

I've created a parser for our projects which takes the model classes from Swagger as the input and it generates the class we need as the output. However I've realised that would be easier if we can retrieve the whole list of methods in a single file/url. For example:

INPUT:
Pet {
id
(integer, optional),
category
(Category, optional),
name
(string),
photoUrls
(Array[string]),
tags
(Array[Tag], optional),
status
(string, optional): pet status in the store = ['available', 'pending', 'sold']
}


OUTPUT:
public class Pet: Mappable {

   
var id: Int?
   
var category: Category?
   
var tags: Array[Tag]?
   
var status: String?

    required
public init?(_ map: Map) {
   
}

   
public func mapping(map: Map) {
        id
<- map["id"]
        category
<- map["category"]
        tags
<- map["tags"]
        status
<- map["status"]
   
}
}

So the idea was to use the COMPLETE model list to generate all the needed classes at the same time, for example, you pass two models:

INPUT:
Pet {
id
(integer, optional),
category
(Category, optional),
name
(string),
photoUrls
(Array[string]),
tags
(Array[Tag], optional),
status
(string, optional): pet status in the store = ['available', 'pending', 'sold']
}

Horse {
id
(integer, optional),
category
(Category, optional),
name
(string),
photoUrls
(Array[string]),
tags
(Array[Tag], optional),
status
(string, optional): pet status in the store = ['available', 'pending', 'sold']
}

And the output would generate two files with the two model implementations. So my question again is: Is there any way to get all the models from the same page and format? (ideally raw so I can simply copy everything). Please I'm searching something different than tapping on "Model" for each endpoint.

Finally, is there any API to connect to Swagger using an authentication like OAuth, so I only need to set the client id and secret?

Many thanks!

Jose Martinez

unread,
Aug 30, 2016, 8:30:38 PM8/30/16
to Swagger
I'm searching something similar to this: http://petstore.swagger.io/v2/swagger.json but with the model classes instead. Thanks.

tony tam

unread,
Aug 30, 2016, 8:31:34 PM8/30/16
to swagger-sw...@googlegroups.com
You mean like Swagger Codegen?

On Aug 30, 2016, at 5:30 PM, Jose Martinez <joam...@gmail.com> wrote:

I'm searching something similar to this: http://petstore.swagger.io/v2/swagger.json but with the model classes instead. Thanks.

--
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.

Reply all
Reply to author
Forward
0 new messages