Successfully reported this slideshow.
Your SlideShare is downloading. ×

the 12 facets of OpenAPI

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 49 Ad

the 12 facets of OpenAPI

Download to read offline

We present how Cisco Engineering uses the OpenAPI specifications to drive API quality and state-of-the-art developer experience. We then describe OpenAPI best practices, tools and processes built internally and opensource'd. Finally, we cover lessons learnt when standardizing on OAS for organizations with a massive API portfolio.

This talk was delivered at API Days Global/Paris on December 14th

We present how Cisco Engineering uses the OpenAPI specifications to drive API quality and state-of-the-art developer experience. We then describe OpenAPI best practices, tools and processes built internally and opensource'd. Finally, we cover lessons learnt when standardizing on OAS for organizations with a massive API portfolio.

This talk was delivered at API Days Global/Paris on December 14th

Advertisement
Advertisement

More Related Content

Similar to the 12 facets of OpenAPI (20)

More from Cisco DevNet (20)

Advertisement

Recently uploaded (20)

the 12 facets of OpenAPI

  1. 1. Stève Sfartz, Principal Architect – Cisco Dec 14th, 2022 the 12 facets of OpenAPI
  2. 2. © 2022 Cisco and/or its affiliates. #apidays /Cisco/DevNet/StèveSfartz • API Architect in Cisco Developer Relations • Technical Lead for API Experience and Cisco API Guidelines: prescriptive standards and best practices for API & SDKs • Working to deliver a great and consistent developer experience across Cisco platforms “vision without execution is hallucination ” webex: stsfartz@cisco.com github: ObjectIsAdvantag twitter: @SteveSfartz linkedin:/stevesfartz 2
  3. 3. #1. OpenAPI to describe API Contracts
  4. 4. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Formalizing API Contracts • For every operation supported by an API, its contract describes: • what must be provided as input • what will happen • and what, if any, data is returned as a result • OpenAPI Specification (OAS) is a standard to define contracts for Web API • Example of OAS document 4
  5. 5. #2. Authoring OAS Documents
  6. 6. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Editing with SwaggerEditor https://editor.swagger.io/ 6
  7. 7. #3. Publish Reference Documentation
  8. 8. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays API Reference Documentation developer.cisco.com/meraki/api-v1/#!create-organization • Automatically rendered from OAS documents 8
  9. 9. #4. Try out API Operations
  10. 10. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 10
  11. 11. #5. Generate Code
  12. 12. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Auto-generate client code • From the documentation itself • From a CLI tool, create client and server code. import requests url="https://api.meraki.com/api/v1/organizations" payload=None headers={ "Content-Type": "application/json", "Accept": "application/json", "X-Cisco-Meraki-API-Key": "6bec40c…9ea0" } response=requests.request('GET', url, headers=headers, data = payload) print(response.text.encode('utf8')) python 12
  13. 13. #6. Mock APIs
  14. 14. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 14 Mocking APIs
  15. 15. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Summary OpenAPI to #1. Describe API contracts #2. Author OAS documents #3. Publish documentation #4. Try out an API #5. Generate Code #6. Mock an API 15
  16. 16. #7. The OpenAPI Specification
  17. 17. © 2022 Cisco and/or its affiliates. All rights reserved #apidays The OpenAPI Initiative Charter https://www.openapis.org/ 17
  18. 18. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 18 Versions of the OpenAPI Specifications full compatibility with modern JSON Schema [Draft 2020-12] OpenAPI 2.0 - 2014 OpenAPI 3.0 - 2017 OpenAPI 3.1 - 2021
  19. 19. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays OAS v3.0 as the default import format https://www.apimatic.io/blog/2022/03/top-api-specification-trends-2019-2022/ “Since August 2019, the number of imported OAS v3.0 documents has surpassed OAS v2.0” APIMatic March 2022 19
  20. 20. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays but… OAS v2.0 still largely spread API Specification Transformation Trends 20 “50% users preferred to convert to OpenAPI v2.0 overs 3.0” APIMatic March 2022 • quality of support for OpenAPI v3.0 in tools • legacy tools that still supports v2.0 only.
  21. 21. #8. Terminology
  22. 22. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays API Definition OpenAPI Specification (OAS) OAS document The OpenAPI Specification is a programming language-agnostic standard used to describe the contract for HTTP/REST APIs An OAS document contains the description of the full set or a subset of the API features. OAS document should be read as: “a document that conforms to the OpenAPI Specification” OAS document OAS Document Terminology An API Definition describes the full contract for an API. In the case of HTTP/REST APIs, the API Definition consists in a set of OAS documents. Often, one OAS document will be sufficient to fully define the API. 22
  23. 23. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Terminology • OpenAPI Specification, OpenAPI Initiative, OpenAPI Tools, OpenAPI • OAS Document: describe an API using the OpenAPI Specification • API Contract, API Definition, API Specification/Spec, API Description • API Documentation: the reference documentation for an API, published on a web site, and kept in sync with a version of an API • API Endpoint, API: the URL at which an API version can be accessed, such as ‘https://api.meraki.com/v1/’ • API Path, REST Resource, API: a URL such as ‘/organizations’ • API Operation, API: a Path + a method such as ‘GET /organizations’ 23
  24. 24. © 2022 Cisco and/or its affiliates. #apidays API Guidelines • An API is a network programmatic interface that a product - may be bare metal hardware, or virtual machine or software – AND - may be cloud or on-premises – publishes. • It has versions – it’s the API lifecycle • For every update, an API would publish its contract as one or multiple OAS documents for download or online browsing. • Every API version provides a documentation which includes authentication instructions, developer guides, code samples and reference documentation… and an API changelog. 24
  25. 25. #9. OAS Documents Management & Lifecycle
  26. 26. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays OAS Document Lifecycle Product Manager OAS Document draft 1 Engineering Lead Tech Writer 1. Create initial OAS document 2. Expand OAS document with payload and errors 3. Enrich OAS documents with descriptions and examples developer.cisco.com OAS Document draft 2 OAS Document draft … 4. Integrate with API documentation publishing tool 26
  27. 27. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays OAS Documents Workflow Best Practices Single Source of Truth Define where the OAS documents of your API will be stored • Single source of truth • OAS documents should be checked into a git repo to track changes Clarify Strategy Define who is responsible to merge changes • Whether a product manager, technical writer or technical lead – be consistent • Use GitHub pull requests for tracking and merging changes Educate the Team Educate your team members on OAS • OAS fundamentals • OAS workflow • OAS toolsets (linters, code generators...) Refine the Process Practice and refine as needed • Update OAS documents, review PR and merge changes • Maintain an API Changelog • This workflow may take time to establish 27
  28. 28. #10. Accurate OAS Documents
  29. 29. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Code as the source of truth Convert code comments or annotations 29 paths: "/pets/{category}": post: description: List all pets in a category parameters: - in: path name: category required: true description: Pet category schema: type: string default: all - in: query name: limit description: Amt returned schema: type: integer format: int32 responses: '200': description: Successful response requestBody: content: application/json: schema: type: object properties: search: type: string description: Search pet details strict: type: boolean description: Exact matches? https://openap.is/
  30. 30. #11. Automate Design Reviews
  31. 31. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays OAS Documents Static Analysis Detecting Quality or Security Faults 31
  32. 32. #12. Detecting Drifts and Zombies
  33. 33. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Drifts & Zombies Comparing OAS documents with live traffic observations 33
  34. 34. #13. API Changelogs
  35. 35. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays API Changelog • one operation added • one breaking change detected
  36. 36. #14. API Lifecycle and Compliance Management
  37. 37. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Highly Reliable (Lifecycle with deprecation notices, complete & accurate definition, complete changelog) API Contract Health Unreliable (Breaking changes, no or partial changelog, typically unstructured or UI-led design) Evolving (Product-tied versions, changelogs and contract may not be complete, ie typically UI-led design) Versioned (API-specific lifecycle, definition published with large coverage, complete changelog) Trust API Contract Roadmap <18m feb22 evolving versioned API Contract Health as the plan was established Timeline to execute the plan and improve the contract Contract Health after the plan will be completed 37
  38. 38. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 38 API Lifecycle, Quality and Compliance https://developer.cisco.com/api-insights/
  39. 39. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 39
  40. 40. #15. OpenAPI Tools and Communities
  41. 41. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays openapi.tools/ 41
  42. 42. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays 42 OpenAPI Communities stoplight.io/api-roadmap-ebook techblog.cisco.com
  43. 43. Wrapup
  44. 44. © 2022 Cisco and/or its affiliates. All rights reserved. #apidays Who you are Benefits IT Pro or Application Developer consuming APIs • OAS to discover the capabilities of an API • OAS to automatically generate client code for your preferred language • OAS as a pivot format to import/export API definitions across tools Engineering group publishing internal or external-facing APIs • OAS to define the capabilities offered for your API • OAS to publish low-level SDKs • OAS to publish accurate and interactive documentation • OAS to automate raw API Changelogs • Authoring tools to initiate/edit OAS documents (Design-First) • Source code annotations to generate OAS documents (Code-First) • OAS linters to automate design reviews and adoption of REST Guidelines • Static & dynamic analysis of API Security issues including OWASP Top 10 Security and Compliance Officers overseeing every APIs • OAS to maintain an inventory of an organization’s APIs • Analysis of OAS documents to identify breaking changes and ensure backward compatibility of existing API Contracts • OAS to ensure compliance of new releases along CI/CD pipelines • OAS to identify zombie & shadow operations via live traffic observations 44 blogs.cisco.com/developer/worldclassapis01
  45. 45. Lorem Ipsum cs.co/insight
  46. 46. Enter to win! http://cs.co/apidays Answer a few questions and enter to win Festavia string lights!
  47. 47. Develop: Secure It, Cloud It, Code It Apply to be a speaker today! cs.co/apispeakers
  48. 48. Thank You!
  49. 49. APIs the next 10 years: Software, Society, Sovereignty, Sustainability December 14, 15 & 16, 2022 Stève Sfartz Principal Architect, Cisco

×