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

Swagger Codegen

wagyu298
March 03, 2017

Swagger Codegen

Swagger Codegen の使い方の簡単な説明です。

wagyu298

March 03, 2017
Tweet

More Decks by wagyu298

Other Decks in Programming

Transcript

  1. 4XBHHFS w 0QFO"1*ͷ͜ͱ w IUUQTXBHHFSJP w IUUQTXXXPQFOBQJTPSH w αϯϓϧIUUQQFUTUPSFTXBHHFSJPW TXBHHFSZBNM

    w 3&45"1*ఆٛϑΝΠϧΛ:".-Ͱهड़͠ɺωοτϫʔ Ϋӽ͠ʹ࢓༷Λ఻ൖͤͨ͞Γ͍ͨ͠ײ͡ͷ΍ͭ
  2. BOESPJE BTQOFU BTQOFUDPSF BTZODTDBMB CBTI DXJLJ  DTIBSQ DQQSFTU EBSU

    FMJYJS qBTI QZUIPOqBTL HP  HSPPWZ KBWB KBYST KBYSTDYGDMJFOU KBYSTDYG KBYST SFTUFBTZ KBYSTTQFD KBYSTDYGDEJ JOqFDUPS KBWBTDSJQU  KBWBTDSJQUDMPTVSFBOHVMBS KNFUFS OBODZGY 
 OPEFKTTFSWFS PCKD QFSM QIQ QZUIPO RUDQQ SVCZ  TDBMB TDBMBUSB pODI TJMFY1)1 TJOBUSB SBJMT TMJN  TQSJOH EZOBNJDIUNM IUNM IUNM TXBHHFS TXBHHFS ZBNM TXJGU TXJGU UJ[FO UZQFTDSJQUBOHVMBS  UZQFTDSJQUBOHVMBS UZQFTDSJQUOPEF UZQFTDSJQUGFUDI  BLLBTDBMB $TIBSQ%PU/FU DMPKVSF IBTLFMM MVNFO 
 HPTFSWFS FSMBOHTFSWFS VOEFSUPX NTGK [FQI
  3. 4FSWFS4UVCͷ࡞੒ bash-3.2$ java -jar swagger-codegen-cli.jar generate -i swagger.yaml - l

    nodejs-server -o nodejs bash-3.2$ cd nodejs bash-3.2$ npm install bash-3.2$ node index.js Your server is listening on port 8080 (http://localhost:8080) Swagger-ui is available on http://localhost:8080/docs IUUQMPDBMIPTUWQFUͰΞΫηεͰ͖·͢
  4. J04$MJFOU"1*ͷ࡞੒ bash-3.2$ java -jar swagger-codegen-cli.jar generate -i swagger.yaml -l swift3

    -o PetShop -DprojectName=PetShop $PDPB1PETϥΠϒϥϦ1FU4IPQ"1*͕Ͱ͖·͢ "1*ݺͼग़͠͸"MBNPpSFͰ͢ "OESPJE͸WPMMFZͰ͢
  5. QPETQFD౳͕एׯݹ͍ͷͰ ͍͘͡Γ·͢ # Uncomment this line to define a global

    platform for your project # platform :ios, '9.0' target 'SwaggerExam' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for SwaggerExam pod 'PetShopAPI', :path => '../PetShopAPI' target 'SwaggerExamTests' do inherit! :search_paths # Pods for testing end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end end
  6. ʢ͕࣌ؒແ͍ͷͰʣ"1*Λݺ ͼग़ͯ͠ϩάදࣔ͠·͢ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)

    -> Bool { // Override point for customization after application launch. PetShopAPI.basePath = "http://localhost:8080/v2" PetAPI.getPetById(petId: 12) { (pet, error) in if let error = error { print(error) return } guard let pet = pet else { return } print(pet.encodeToJSON()) } return true } *OGPQMJTUʹBQQUSBOTQPSUTFDVSJUZͷઃఆ͕ඞཁ
  7. 4FSWFS4UVCΛHPMBOHʹม ͑ͯΈ·͢ bash-3.2$ java -jar swagger-codegen-cli.jar generate -i swagger.yaml -l

    go-server -o go-server -DpackageName=petshop OPEFTFSWFSͱҟͳΓςετ༻ͷσʔλ͕ ؼͬͯ͜ͳ͍ͷͰΤϥʔʹͳΓ·͢