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

SchemaDrivenDevelopment

 SchemaDrivenDevelopment

atomiyama

March 24, 2021
Tweet

More Decks by atomiyama

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ ✎ 2018/09~ Studyplusೖࣾ ✎ 29ࡀ ✎ ؠखݝࡏॅ ✎ ޷͖ͳݴޠɿRuby,

    Rust ෌ࢁথ࢙ Akifumi Tomiyama atomiyama atomiyama1216 Studyplus Inc. ForSchool Dept. 
 CX Product Group Team Lead.
  2. ࢖͍ͬͯΔπʔϧ OpenAPI 3.0 
 REST APIΛఆٛ͢ΔͨΊඪ४࢓༷ Swagger UI 
 APIεΩʔϚͷ֬ೝ

    Gems • committee 
 ϦΫΤετɼϨεϙϯεόϦσʔγϣϯɼςετΞαʔγϣϯ • json_refs 
 ෳ਺ϑΝΠϧ؅ཧ࣌ͷrefͷղܾ
  3. APIεΩʔϚఆٛϑΝΠϧ؅ཧ • main.yaml 
 ΞϓϦέʔγϣϯͷఆٛʢೝূͳͲ • paths.yamlɼpath/* 
 ΤϯυϙΠϯτͷఆٛ •

    schemas.yaml, schemas/* 
 ϦιʔεͷఆٛʢϞσϧͱରԠ • parameters.yaml, parameters/* 
 ڞ௨ύϥϝʔλͷఆٛ • responses.yaml, responses/* 
 ڞ௨Ϩεϙϯεͷఆٛ > tree -L 3 swagger/api/v1 ├── components │ ├── schemas.yaml │ ├── parameters.yaml │ ├── responses.yaml │ ├── parameters │ │ ├── section_id.yaml │ │ └── student_id.yaml │ ├── schemas │ │ ├── section.yaml │ │ └── student.yaml ├── paths │ └── sections │ └── index.yaml ├── paths.yaml └── main.yaml
  4. APIεΩʔϚఆٛϑΝΠϧ؅ཧ • main.yaml 
 ΞϓϦέʔγϣϯͷఆٛʢೝূͳͲ • paths.yamlɼpath/* 
 ΤϯυϙΠϯτͷఆٛ •

    schemas.yaml, schemas/* 
 ϦιʔεͷఆٛʢϞσϧͱରԠ • parameters.yaml, parameters/* 
 ڞ௨ύϥϝʔλͷఆٛ • responses.yaml, responses/* 
 ڞ௨Ϩεϙϯεͷఆٛ > tree -L 3 swagger/api/v1 ├── components │ ├── schemas.yaml │ ├── parameters.yaml │ ├── responses.yaml │ ├── parameters │ │ ├── section_id.yaml │ │ └── student_id.yaml │ ├── schemas │ │ ├── section.yaml │ │ └── student.yaml ├── paths │ └── sections │ └── index.yaml ├── paths.yaml └── main.yaml
  5. εΩʔϚόϦσʔγϣϯ • ࣮૷ͱεΩʔϚͷဃ཭๷ࢭ - request specͰอূ - ͢΂ͯͷϨεϙϯε͕ఆٛͱဃ཭͠ ͍ͯͳ͍͔assert_schema_conform Ͱ֬ೝ

    - ෳ਺ͷAPIʢ಺෦ެ։ɼ֎෦ެ։ʣ ͕͋ΔͷͰRSpecͷmetadataʹ OpenAPIఆٛϑΝΠϧύεΛࢦఆͰ ͖ΔΑ͏ʹ͍ͯ͠Δ