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

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

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. From API specifications to
    code with OpenAPI


    View Slide

  2. 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

    View Slide

  3. The API economy is on fire 🔥


    OpenAPI to the rescue 💦

    View Slide

  4. Developer Experience


    Code generation


    Adyen way of APIs


    OpenAPI


    Agenda

    View Slide

  5. Developer Advocate
    Me
    @beppecatanese
    gcatanese

    View Slide

  6. Adyen
    Financial technology
    Large merchants


    and marketplaces 3 technical hubs

    View Slide

  7. OpenAPI “Lingua Franca”


    Wordnik, Swagger


    OpenAPI initiative


    Code generation


    Validator


    Diff


    OpenAPI & OpenAPI Generator

    View Slide

  8. Client Server 100+ languages Configuration Documentation
    CLI Docker Jar Maven Gradle
    Code generation

    View Slide

  9. The Adyen way

    View Slide

  10. API Explorer

    View Slide

  11. 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?

    View Slide

  12. 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?

    View Slide

  13. SDK developer workflow
    Generate Release Repeat

    View Slide

  14. • Logic-less


    • Source code, config, documentation


    • Tags: variables, sections, lists
    Mustache templates
    Separation of concerns done right

    View Slide

  15. Hello {{name}}
    Mustache template variable
    {


    “name”: “Beppe”


    }
    (template)
    (data)
    Hello Beppe

    View Slide

  16. {{#param}}


    if {{#name}} != null {


    // do something


    }


    {{/param}}
    Mustache template section tag
    {


    “param”:


    {“name”:”city”}


    }
    (template)
    (data)
    if city != null {


    // do something


    }

    View Slide

  17. {{#allParams}}


    {{type}} p{{name}},


    {{/allParams}}
    Mustache template list
    [


    {“type”: “String”, “name”: “City”},


    {“type”: “String”, “name”: “Country”}


    ]
    (data)
    String pCity, String pCountry,
    (template)

    View Slide

  18. Fetch templates
    openapi-generator-cli author template -g spring \
    -o tmp/myspringtemplate
    Demo or not demo?

    View Slide

  19. 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?

    View Slide

  20. Practices
    (re)Generate code
    Generate models


    and/or services
    Skip files

    View Slide

  21. Challenges
    Specs evolve Templates change Manual changes

    View Slide

  22. Developer Experience


    github.com/adyen


    github.com/adyen/adyen-openapi
    Final thoughts

    View Slide

  23. Thank You!

    View Slide