SlideShare a Scribd company logo
1 of 47
Download to read offline
OpenAPI Bes t Pract ices
for generat ing SDKs
Sid Maes t re
VP Developer Relations @APIMatic
Benefits of generated SDKs
● Your API definition is the source of truth
● Updates can be rolled out in multiple SDKs.
● Building SDKs and documentation part of your CI/ CD pipeline.
● Updates are more accurate and less time consuming.
● Focus engineering resources on building new features, not SDKs.
3 ways to create an API definition
Manually Annotation HTTP Traffic
Converting your definition
Validate your definition
Pitfall #1
Omitting operation ids
/pets:
post:
tags:
- pets
summary: Updates a pet in the store with form data
description: Updates an existing pet and characteristics
parameters: []
… or duplicate operation id
/pets:
post:
operationId: updatePet
summary: Updates a pet in the store with form data
put:
operationId: updatePet
summary: Updates a pet in the store with form data
include a unique operation id
/pets:
post:
tags:
- pets
summary: Updates a pet in the store with form data
operationId: updatePet
description: Updates an existing pet and characteristics
parameters: []
Spectral with standard ruleset
● Duplicate operationId (error)
● No operation Id (warning)
💡💡 Tips for naming your operationId
● Use name pattern of a verb + object/ resource.
● Aim to be 30 characters or less
● Avoid using stop words like "a", "the" and "and" in the name.
● createPet / updatePet / listPets
Pitfall #2
Omitting tags from operations
/pets:
post:
summary: Updates a pet in the store with form data
operationId: updatePet
description: Updates an existing pet and characteristics
parameters: []
/pets:
Post:
tags:
- pets
summary: Updates a pet in the store with form data
operationId: updatePet
description: Updates an existing pet and characteristics
parameters: []
Spectral with standard ruleset
● Operations missing tag property (warning)
💡💡 Tips for naming tags
● Identify the ideal groupings for your methods.
● Pluralize all names unless they are singleton resources.
● Aim to be 30 characters or less
● petsController
Pitfall #3
Poorly written or no descriptions
The following should have descriptions
● Info
● Tag
● Operations and Parameters
● Request body
● Response content
● Schema and schema properties
Spectral with standard ruleset
● Response content (error)
● Info (warning)
● Tag (warning)
● Operations (warning) and Parameters
● Request body
● Schema and schema properties
💡💡 Tips for writing good descriptions
● Describe the element and mention any edge cases that may occur
● Avoid short descriptions that don’t add value.
Describe the response from the listPets operation
⛔ description: list response
✅ description: A paged array of pets
Pitfall #4
Defining objects or enums inline
public List<PetsResponse> listPets(
final Integer limit) throws ApiException, IOException {
return prepareListPetsRequest(limit).execute();
}
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
name:
petType:
public List<Pet> listPets(
final Integer limit) throws ApiException, IOException {
return prepareListPetsRequest(limit).execute();
}
Define them as reusable components
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
Spectral with standard ruleset
● None
💡💡 Tips for naming objects
● Use singular unless it represents some kind of collection of things
● Do not prefix or postfix based on their schema type.
⛔ PetsResponse
⛔ PetObject
✅ Pet
Pitfall #5
Forgetting examples
The following should have examples
● Parameters
● Request body
● Response content
● Schema and schema properties
@Test
public void testTestUpdatePet() throws Exception {
Pet body = ApiHelper.deserialize(
"{"id":12345,"name":"Indiana","petType":"dog"}",
Pet.class);
try {
controller.updatePet(body);
} catch (ApiException e) {
// Empty block
}
assertNotNull("Response is null",
httpResponse.getResponse());
assertEquals("Status is not 201",
201, httpResponse.getResponse().getStatusCode());
Spectral with standard ruleset
● None
10 Traps
SDK generators
Questions?
apidays New York 2023 - OpenAPI Best Practices for Generating SDKs, Sid Maestre, APIMatic

More Related Content

Similar to apidays New York 2023 - OpenAPI Best Practices for Generating SDKs, Sid Maestre, APIMatic

Interview qutions
Interview qutionsInterview qutions
Interview qutions
satyaragha
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design Principles
Anji Beeravalli
 

Similar to apidays New York 2023 - OpenAPI Best Practices for Generating SDKs, Sid Maestre, APIMatic (20)

R12 d49656 gc10-apps dba 09
R12 d49656 gc10-apps dba 09R12 d49656 gc10-apps dba 09
R12 d49656 gc10-apps dba 09
 
Dhanasekaran 2008-2009 Quick Test Pro Presentation
Dhanasekaran 2008-2009 Quick Test Pro PresentationDhanasekaran 2008-2009 Quick Test Pro Presentation
Dhanasekaran 2008-2009 Quick Test Pro Presentation
 
First QTP Tutorial
First QTP TutorialFirst QTP Tutorial
First QTP Tutorial
 
QTP Tutorial Slides Presentation.
QTP Tutorial Slides Presentation.QTP Tutorial Slides Presentation.
QTP Tutorial Slides Presentation.
 
Configure Your Projects with Apache Tamaya
Configure Your Projects with Apache TamayaConfigure Your Projects with Apache Tamaya
Configure Your Projects with Apache Tamaya
 
06 chapter03 04_control_logix_tags_memory_structure_fa16
06 chapter03 04_control_logix_tags_memory_structure_fa1606 chapter03 04_control_logix_tags_memory_structure_fa16
06 chapter03 04_control_logix_tags_memory_structure_fa16
 
MaxTECH Technical Training - Maximo Custom Audit Solution
MaxTECH Technical Training - Maximo Custom Audit SolutionMaxTECH Technical Training - Maximo Custom Audit Solution
MaxTECH Technical Training - Maximo Custom Audit Solution
 
Boost your App with Gatling
Boost your App with GatlingBoost your App with Gatling
Boost your App with Gatling
 
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
 
DA 592 - Term Project Presentation - Berker Kozan Can Koklu - Kaggle Contest
DA 592 - Term Project Presentation - Berker Kozan Can Koklu - Kaggle ContestDA 592 - Term Project Presentation - Berker Kozan Can Koklu - Kaggle Contest
DA 592 - Term Project Presentation - Berker Kozan Can Koklu - Kaggle Contest
 
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
 
Lemur Tutorial at SIGIR 2006
Lemur Tutorial at SIGIR 2006Lemur Tutorial at SIGIR 2006
Lemur Tutorial at SIGIR 2006
 
PA I Session I Recap
PA I Session I RecapPA I Session I Recap
PA I Session I Recap
 
Pa1 session 1_recap
Pa1 session 1_recapPa1 session 1_recap
Pa1 session 1_recap
 
Interview qutions
Interview qutionsInterview qutions
Interview qutions
 
11i&r12 difference
11i&r12 difference11i&r12 difference
11i&r12 difference
 
Making Postgres Central in Your Data Center
Making Postgres Central in Your Data CenterMaking Postgres Central in Your Data Center
Making Postgres Central in Your Data Center
 
Web REST APIs Design Principles
Web REST APIs Design PrinciplesWeb REST APIs Design Principles
Web REST APIs Design Principles
 
Postgres в основе вашего дата-центра, Bruce Momjian (EnterpriseDB)
Postgres в основе вашего дата-центра, Bruce Momjian (EnterpriseDB)Postgres в основе вашего дата-центра, Bruce Momjian (EnterpriseDB)
Postgres в основе вашего дата-центра, Bruce Momjian (EnterpriseDB)
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing Services
 

More from apidays

More from apidays (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The secrets to Graph success, by Leah Hurwich Adler, ...
Apidays New York 2024 - The secrets to Graph success, by Leah Hurwich Adler, ...Apidays New York 2024 - The secrets to Graph success, by Leah Hurwich Adler, ...
Apidays New York 2024 - The secrets to Graph success, by Leah Hurwich Adler, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
Apidays New York 2024 - API Discovery - From Crawl to Run by Rob Dickinson, G...
 
Apidays Singapore 2024 - Building with the Planet in Mind by Sandeep Joshi, M...
Apidays Singapore 2024 - Building with the Planet in Mind by Sandeep Joshi, M...Apidays Singapore 2024 - Building with the Planet in Mind by Sandeep Joshi, M...
Apidays Singapore 2024 - Building with the Planet in Mind by Sandeep Joshi, M...
 
Apidays Singapore 2024 - Connecting Cross Border Commerce with Payments by Gu...
Apidays Singapore 2024 - Connecting Cross Border Commerce with Payments by Gu...Apidays Singapore 2024 - Connecting Cross Border Commerce with Payments by Gu...
Apidays Singapore 2024 - Connecting Cross Border Commerce with Payments by Gu...
 
Apidays Singapore 2024 - Privacy Enhancing Technologies for AI by Mark Choo, ...
Apidays Singapore 2024 - Privacy Enhancing Technologies for AI by Mark Choo, ...Apidays Singapore 2024 - Privacy Enhancing Technologies for AI by Mark Choo, ...
Apidays Singapore 2024 - Privacy Enhancing Technologies for AI by Mark Choo, ...
 
Apidays Singapore 2024 - Blending AI and IoT for Smarter Health by Matthew Ch...
Apidays Singapore 2024 - Blending AI and IoT for Smarter Health by Matthew Ch...Apidays Singapore 2024 - Blending AI and IoT for Smarter Health by Matthew Ch...
Apidays Singapore 2024 - Blending AI and IoT for Smarter Health by Matthew Ch...
 
Apidays Singapore 2024 - OpenTelemetry for API Monitoring by Danielle Kayumbi...
Apidays Singapore 2024 - OpenTelemetry for API Monitoring by Danielle Kayumbi...Apidays Singapore 2024 - OpenTelemetry for API Monitoring by Danielle Kayumbi...
Apidays Singapore 2024 - OpenTelemetry for API Monitoring by Danielle Kayumbi...
 
Apidays Singapore 2024 - Connecting Product and Engineering Teams with Testin...
Apidays Singapore 2024 - Connecting Product and Engineering Teams with Testin...Apidays Singapore 2024 - Connecting Product and Engineering Teams with Testin...
Apidays Singapore 2024 - Connecting Product and Engineering Teams with Testin...
 
Apidays Singapore 2024 - The Growing Carbon Footprint of Digitalization and H...
Apidays Singapore 2024 - The Growing Carbon Footprint of Digitalization and H...Apidays Singapore 2024 - The Growing Carbon Footprint of Digitalization and H...
Apidays Singapore 2024 - The Growing Carbon Footprint of Digitalization and H...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays Singapore 2024 - API Monitoring x SRE by Ryan Ashneil and Eugene Wong...
Apidays Singapore 2024 - API Monitoring x SRE by Ryan Ashneil and Eugene Wong...Apidays Singapore 2024 - API Monitoring x SRE by Ryan Ashneil and Eugene Wong...
Apidays Singapore 2024 - API Monitoring x SRE by Ryan Ashneil and Eugene Wong...
 
Apidays Singapore 2024 - A nuanced approach on AI costs and benefits for the ...
Apidays Singapore 2024 - A nuanced approach on AI costs and benefits for the ...Apidays Singapore 2024 - A nuanced approach on AI costs and benefits for the ...
Apidays Singapore 2024 - A nuanced approach on AI costs and benefits for the ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - How APIs drive business at BNP Paribas by Quy-Doan D...
Apidays Singapore 2024 - How APIs drive business at BNP Paribas by Quy-Doan D...Apidays Singapore 2024 - How APIs drive business at BNP Paribas by Quy-Doan D...
Apidays Singapore 2024 - How APIs drive business at BNP Paribas by Quy-Doan D...
 

Recently uploaded

obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
yulianti213969
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
 
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotecAbortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
pwgnohujw
 
Simplify hybrid data integration at an enterprise scale. Integrate all your d...
Simplify hybrid data integration at an enterprise scale. Integrate all your d...Simplify hybrid data integration at an enterprise scale. Integrate all your d...
Simplify hybrid data integration at an enterprise scale. Integrate all your d...
varanasisatyanvesh
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444
saurabvyas476
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
q6pzkpark
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
wsppdmt
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
acoha1
 

Recently uploaded (20)

obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital AgeCredit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotecAbortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotec
 
Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?
 
jll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdfjll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdf
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
 
Simplify hybrid data integration at an enterprise scale. Integrate all your d...
Simplify hybrid data integration at an enterprise scale. Integrate all your d...Simplify hybrid data integration at an enterprise scale. Integrate all your d...
Simplify hybrid data integration at an enterprise scale. Integrate all your d...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
DS Lecture-1 about discrete structure .ppt
DS Lecture-1 about discrete structure .pptDS Lecture-1 about discrete structure .ppt
DS Lecture-1 about discrete structure .ppt
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 

apidays New York 2023 - OpenAPI Best Practices for Generating SDKs, Sid Maestre, APIMatic

  • 1. OpenAPI Bes t Pract ices for generat ing SDKs Sid Maes t re VP Developer Relations @APIMatic
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Benefits of generated SDKs ● Your API definition is the source of truth ● Updates can be rolled out in multiple SDKs. ● Building SDKs and documentation part of your CI/ CD pipeline. ● Updates are more accurate and less time consuming. ● Focus engineering resources on building new features, not SDKs.
  • 12. 3 ways to create an API definition Manually Annotation HTTP Traffic
  • 15.
  • 17. /pets: post: tags: - pets summary: Updates a pet in the store with form data description: Updates an existing pet and characteristics parameters: []
  • 18. … or duplicate operation id /pets: post: operationId: updatePet summary: Updates a pet in the store with form data put: operationId: updatePet summary: Updates a pet in the store with form data
  • 19. include a unique operation id /pets: post: tags: - pets summary: Updates a pet in the store with form data operationId: updatePet description: Updates an existing pet and characteristics parameters: []
  • 20. Spectral with standard ruleset ● Duplicate operationId (error) ● No operation Id (warning)
  • 21. 💡💡 Tips for naming your operationId ● Use name pattern of a verb + object/ resource. ● Aim to be 30 characters or less ● Avoid using stop words like "a", "the" and "and" in the name. ● createPet / updatePet / listPets
  • 22. Pitfall #2 Omitting tags from operations
  • 23. /pets: post: summary: Updates a pet in the store with form data operationId: updatePet description: Updates an existing pet and characteristics parameters: []
  • 24. /pets: Post: tags: - pets summary: Updates a pet in the store with form data operationId: updatePet description: Updates an existing pet and characteristics parameters: []
  • 25. Spectral with standard ruleset ● Operations missing tag property (warning)
  • 26. 💡💡 Tips for naming tags ● Identify the ideal groupings for your methods. ● Pluralize all names unless they are singleton resources. ● Aim to be 30 characters or less ● petsController
  • 27. Pitfall #3 Poorly written or no descriptions
  • 28. The following should have descriptions ● Info ● Tag ● Operations and Parameters ● Request body ● Response content ● Schema and schema properties
  • 29. Spectral with standard ruleset ● Response content (error) ● Info (warning) ● Tag (warning) ● Operations (warning) and Parameters ● Request body ● Schema and schema properties
  • 30. 💡💡 Tips for writing good descriptions ● Describe the element and mention any edge cases that may occur ● Avoid short descriptions that don’t add value. Describe the response from the listPets operation ⛔ description: list response ✅ description: A paged array of pets
  • 31. Pitfall #4 Defining objects or enums inline
  • 32. public List<PetsResponse> listPets( final Integer limit) throws ApiException, IOException { return prepareListPetsRequest(limit).execute(); } content: application/json: schema: type: array items: type: object properties: id: name: petType:
  • 33. public List<Pet> listPets( final Integer limit) throws ApiException, IOException { return prepareListPetsRequest(limit).execute(); } Define them as reusable components content: application/json: schema: $ref: '#/components/schemas/Pet'
  • 34. Spectral with standard ruleset ● None
  • 35. 💡💡 Tips for naming objects ● Use singular unless it represents some kind of collection of things ● Do not prefix or postfix based on their schema type. ⛔ PetsResponse ⛔ PetObject ✅ Pet
  • 37. The following should have examples ● Parameters ● Request body ● Response content ● Schema and schema properties
  • 38.
  • 39.
  • 40. @Test public void testTestUpdatePet() throws Exception { Pet body = ApiHelper.deserialize( "{"id":12345,"name":"Indiana","petType":"dog"}", Pet.class); try { controller.updatePet(body); } catch (ApiException e) { // Empty block } assertNotNull("Response is null", httpResponse.getResponse()); assertEquals("Status is not 201", 201, httpResponse.getResponse().getStatusCode());
  • 41. Spectral with standard ruleset ● None
  • 44.
  • 45.