Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Integrate RESTful API with Swagger-codegen

d_date
April 14, 2018

Continuous Integrate RESTful API with Swagger-codegen

2018/4/14 Hakata.swift #1

d_date

April 14, 2018
Tweet

More Decks by d_date

Other Decks in Programming

Transcript

  1. • Managing your API Spec (Open API Spec: OAS) with

    yaml file • Generate client / server side code with swagger-codegen • Building Mock server
  2. Swagger-Codegen for Swift • Swift 4.1 available (still using flatMap:

    not compactMap:) • Codable protocol • Required / Optional with Swift.Optional • API Client with Alamofire • RxSwift / PromiseKit / Default interface
  3. Automation with Swagger • circleci/openjdk:8-jdk-browsers • Run java -jar swagger-codegen-cli.jar

    generate -l swift4 -l swagger.yaml • Commit & push to github • Publish your code to Github Release (to make latest build) Upload client code to repo for api curl -H “Authorization: token $(GITHUB_ACCESS_TOKEN)” -X POST -d “{\”tag_name\”: \”$API_VERSION\”} -v https://github.com/repos/ #{organization name}/{repo name}/releases API.framework
  4. Automation with Swagger • brew tap yonaskolb/XcodeGen https://github.com/yonaskolb/Xcodegen.git | brew

    install XcodeGen • xcodegen • Git push • Carthage build —no-skip-current —platform iOS | Carthage archive • Sh git_release.sh github_api_token=${GITHUB_ACCESS_TOKEN} owner={owner} repo={repo name} tag=LATEST filename=API.framework.zip (to upload your framework as binary) Generating xcode project for api client API.framework
  5. Automation with Swagger • Write github {organization name}/{repo name} in

    your Cartfile • Run carthage update —platform iOS Download latest framework with Carthage API.framework
  6. XcodeGen • Specify all your properties in your project.yml •

    Targets • Dependencies (cocoapods / Carthage) • settings ( reveal on project settings) • Scheme • Build scripts • Just run `xcodegen` Build your pbxproj. with project.yml
  7. Recap • Managing your API spec with Swagger • Building

    your API Client with Swagger-codegen • You can get Continuous Integrated API Client with Swagger-codegen x Cirlcle CI • You can get latest maintained Swagger-codegen with your PR