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

5分くらいでわかるSwagger / 5minutes-swagger

Takumi Endo
November 09, 2015

5分くらいでわかるSwagger / 5minutes-swagger

Takumi Endo

November 09, 2015
Tweet

More Decks by Takumi Endo

Other Decks in Programming

Transcript

  1. 4XBHHFS 4QFD +40/:".- ίʔυ +BWB 1)1౳ʣ ! 4XBHHFS6* "84"1*(BUFXBZ ֎෦࿈ܞ

    4XBHHFS $PEFHFO ಡΈࠐΈ "NB[PO"1* (BUFXBZ*NQPSUFS ΤίγεςϜ 4XBHHFS&EJUPS ʢΦϯϥΠϯΤσΟλʣ
  2. 4XBHHFS4QFDͷߏ଄ جຊ৘ใ swagger ! info! host! schemes! basePath! tags! produces

    "1*ఆٛ Ϟσϧఆٛ paths definitions \ \ \ ˞ඞਢ߲໨ ʢ஫ʣ͜ΕͰશͯͰ͸ͳ͍Ͱ͢
  3. جຊ৘ใ swagger: '2.0'! info:! title: Sample API! description: Swagger Sample!

    host: xxx.sample.jp! schemes:! - https! basePath: /api! tags:! - name: User! description: Ϣʔβ! produces:! - application/json :".-Ͱͷྫ ʢجຊ͸+40/Ͱ΋ಉ͡ʣ IUUQ IUUQT XT XTTͷ ͲΕ͔
  4. Ϟσϧఆٛ ϦΫΤετ΍ϨεϙϯεͰ࢖͏σʔλܕΛϞσϧͱͯ͠ఆ͍ٛͯ͘͠ ˞JE OBNF BHFͱ͍͏ ͭͷϑΟʔϧυΛ΋ͭ 6TFSϞσϧΛఆٛ͢Δྫ definitions:! User:! type:

    object! properties:! id:! type: integer! description: id of user! name:! type: string! description: name of user! age:! type: number! description: age of user Ϟσϧ໊
  5. paths:! /users/{id}:! get:! summary: get user list! description: xxx! parameters:!

    - name: id! in: path! required: false! type: integer! tags:! - User! responses:! '200'! description: user list! schema:! $ref: '#/definitions/User' "1*ఆٛ ఆٛͨ͠6TFS ϞσϧΛฦ͢ RVFSZ IFBEFS QBUI  CPEZ GPSN%BUBͷ ͲΕ͔ )551ϝιου )551Ϩεϙϯεͷ ఆٛ෼ྻڍ