All Projects → drinking → SwiftAPI

drinking / SwiftAPI

Licence: other
Swift API Code generator based on APIBluePrint

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to SwiftAPI

http-method
🍇 Provides constants for HTTP request methods.
Stars: ✭ 83 (+93.02%)
Mutual labels:  request
get-it
Composable HTTP request library for node and browsers
Stars: ✭ 19 (-55.81%)
Mutual labels:  request
WaterPipe
URL routing framework, requests/responses handler, and HTTP client for PHP
Stars: ✭ 24 (-44.19%)
Mutual labels:  request
node-match-path
Matches a URL against a path. Parameters, wildcards, RegExp.
Stars: ✭ 30 (-30.23%)
Mutual labels:  request
oh-my-request
🔮 simple request library by java8
Stars: ✭ 41 (-4.65%)
Mutual labels:  request
nestjs-cls
A continuation-local storage (async context) module compatible with NestJS's dependency injection.
Stars: ✭ 110 (+155.81%)
Mutual labels:  request
reqres
Powerful classes for http requests and responses
Stars: ✭ 36 (-16.28%)
Mutual labels:  request
AjaxHandler
ASimple PHP Class to help handling Ajax Requests easily
Stars: ✭ 30 (-30.23%)
Mutual labels:  request
rxrest
Reactive rest library
Stars: ✭ 33 (-23.26%)
Mutual labels:  request
openapi4j
OpenAPI 3 parser, JSON schema and request validator.
Stars: ✭ 92 (+113.95%)
Mutual labels:  request
httper
An asynchronous HTTP(S) client built on top of hyper.
Stars: ✭ 16 (-62.79%)
Mutual labels:  request
request-on-steroids
An HTTP client ✨ with retry, circuit-breaker and tor support 📦 out-of-the-box
Stars: ✭ 19 (-55.81%)
Mutual labels:  request
jest-playback
Record and playback http requests from your Jest tests
Stars: ✭ 51 (+18.6%)
Mutual labels:  request
hent
A small utility to fetch remote files into buffers
Stars: ✭ 23 (-46.51%)
Mutual labels:  request
seenreq
Generate an object for testing if a request is sent, request is Mikeal's request.
Stars: ✭ 42 (-2.33%)
Mutual labels:  request
chronosjs
JS Channels (Events / Commands / Reqest-Response / Courier) Mechanism
Stars: ✭ 35 (-18.6%)
Mutual labels:  request
tiny-qiniu-request
tiny-qiniu for rc-upload or antd upload component `customRequest` property
Stars: ✭ 13 (-69.77%)
Mutual labels:  request
miniprogram-network
Redefine the Network API of Wechat MiniProgram (小程序网络库)
Stars: ✭ 93 (+116.28%)
Mutual labels:  request
dredd-rack
The Dredd API blueprint testing tool for your Rack applications.
Stars: ✭ 50 (+16.28%)
Mutual labels:  api-blueprint
router
Fast router for PSR-15 request handlers
Stars: ✭ 18 (-58.14%)
Mutual labels:  request

SwiftAPI

SwiftAPI provides an efficient tool to generate executable Swift API codes from API Blueprint documents directly. And it'll relieve you from trivial works on writing API codes. It also includes some tools to convert JSON to various models, Thanks to Nix Zhu's open source project Coolie .

Install

Install Draft Command line tool, which will help to parse API Blueprint into JSON format AST file.

Usage

Build and Run macOS app SwiftAPIBuilder. Then set input path for apib(API Blueprint format) file and out put path for Swift file. After starting listening, it will automatically translate apib into swift and save code at out put path when editing apib file.

APIService

Generated APIServices wrap Alamofire to do networking request, and use ObjectMapper to map JSON to Mappable model which is also generated by APISwiftBuilder. RxSwift is included to make request observable.

public class GITHUBUSER: PUBLICAPIService<Empty,UserInfo> {
    public class func instance()->PUBLICAPIService<Empty,UserInfo>{
        return PUBLICAPIService<Empty,UserInfo>(subPath:"/users/{name}",method:.get)
    }
}

If several requests share the same host and heads, you can set a global one for their base class. It also can set a custom one if necessary.

PUBLICAPIService<Empty,Empty>.setup(host: "https://api.github.com")

//request with no argument and no observable
GITHUBISSUE.instance().send().response { (response) in
	//do sth...
}

//request with path arguments and observable
let get = GITHUBUSER.instance()
get.fillPathArgs("drinking") //to construct https://api.github.com/users/drinking
get.sendSginal().do(onNext: { (userInfo) in
	//do sth...
 })
 
 //request with Mappable params and observable
 let get = SOMEREQUEST.instance()
get.customHost = "https://www.example.com"
 var params = SOMEREQ()
 params.id = "123456"
 params.name = "drinking"
get.sendSginal(params).do(onNext: { (someResult) in
	//do sth...
 })

SwiftAPIBuilder extract most API attributes into DKTransition, and it's possible and easy to translate to other languages.

UnitTest

SwiftAPIService also includes codes that can run UnitTest directly.

GITHUBISSUE.runTest(testor ,host: "https://api.github.com",expect:{
    let issues = $0.entities;
    expect(issues.count) == 30
});

Convertor

Convertor can translate JSON to ObjectiveC Model、ABIP Model and Swift Mappable Model.

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.0+

Contributing

Bug reports, feature requests and any suggestions on implementations are welcome.

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].