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

apidays Paris 2022 - From API specifications to...

apidays
January 08, 2023

apidays Paris 2022 - From API specifications to code with OpenAPI, Beppe Catanese, Adyen

apidays Paris 2022 - APIs the next 10 years: Software, Society, Sovereignty, Sustainability
December 14, 15 & 16, 2022

From API specifications to code with OpenAPI
Beppe Catanese, Developer Advocate at Adyen
------

Check out our conferences at https://www.apidays.global/

Do you want to sponsor or talk at one of our conferences?
https://apidays.typeform.com/to/ILJeAaV8

Learn more on APIscene, the global media made by the community for the community:
https://www.apiscene.io

Explore the API ecosystem with the API Landscape:
https://apilandscape.apiscene.io/

Deep dive into the API industry with our reports:
https://www.apidays.global/industry-reports/

Subscribe to our global newsletter:
https://apidays.typeform.com/to/i1MPEW

apidays

January 08, 2023
Tweet

More Decks by apidays

Other Decks in Programming

Transcript

  1. 2023 SERIES OF EVENT New York May 16&17 Australia October

    11&12 Singapore April 12&13 Helsinki & North June 5&6 Paris SEPTEMBER London November 15&16 June 28-30 SILICON VALLEY March 14&15 Dubai & Middle East February 22&23
  2. From specs to code openapi: 3.0.0 info: title: My API

    specs paths: ‘/users/{userId}’ parameters: name: userId in: path … get: summary: Get User by ID responses: `200`: content: application/json: … components: schemas: User: …. OpenAPI generator Language? Framework? Source Code Templates Client? Server? Doc?
  3. From specs to Go client openapi-generator-cli generate -i SampleProject.yaml \

    -g go -t tmp/templates -p packageName=User -o tmp/gocodegen Demo or not demo?
  4. • Logic-less • Source code, config, documentation • Tags: variables,

    sections, lists Mustache templates Separation of concerns done right
  5. {{#param}} if {{#name}} != null { // do something }

    {{/param}} Mustache template section tag { “param”: {“name”:”city”} } (template) (data) if city != null { // do something }
  6. {{#allParams}} {{type}} p{{name}}, {{/allParams}} Mustache template list [ {“type”: “String”,

    “name”: “City”}, {“type”: “String”, “name”: “Country”} ] (data) String pCity, String pCountry, (template)
  7. From specs to Java service openapi-generator-cli generate -i SampleProject.yaml -g

    spring \ -p apiPackage=com.adyen.api -p modelPackage=com.adyen.model \ -p groupId=com.adyen -p artifactId=MySampleApp -p artifactVersion=v0.1 \ -p invokerPackage=com.adyen -p con fi gPackage=com.adyen.con fi guration \ -o tmp/javacodegen Demo or not demo?