API API Documentation & Specification 1 — Questions and Answers
Question 1: What is the OpenAPI Specification (OAS) primarily used for?
- Running load tests on APIs
- Defining a standard, machine-readable description of REST APIs (Correct answer)
- Encrypting API traffic
- Managing API rate limits
Correct answer: Defining a standard, machine-readable description of REST APIs
OpenAPI Specification provides a standard YAML/JSON format for describing REST API endpoints, request/response schemas, and authentication methods.
Question 2: Which tool generates interactive API documentation from an OpenAPI Specification file?
- Postman
- Swagger UI (Correct answer)
- JMeter
- Newman
Correct answer: Swagger UI
Swagger UI renders an OpenAPI spec as an interactive web page where developers can read documentation and send real API requests.
Question 3: What is the purpose of an API 'schema' in the context of testing?
- Define which users can access the API
- Describe the structure and data types of request and response bodies (Correct answer)
- Measure API performance
- Log API traffic
Correct answer: Describe the structure and data types of request and response bodies
An API schema formally defines the expected structure, field names, data types, and required fields of request and response payloads.
Question 4: What file format is most commonly used to write OpenAPI Specification files?
- CSV
- XML
- YAML or JSON (Correct answer)
- Markdown
Correct answer: YAML or JSON
OpenAPI Specification files are written in YAML (preferred for readability) or JSON, both of which are equally valid.
Question 5: What does 'API versioning' solve in API design and documentation?
- Improves API response time
- Allows backward-compatible evolution of the API without breaking existing clients (Correct answer)
- Encrypts API payloads
- Manages user authentication
Correct answer: Allows backward-compatible evolution of the API without breaking existing clients
API versioning (e.g., /v1/, /v2/) lets teams introduce breaking changes in new versions while keeping old clients working on previous versions.
Question 6: What is 'design-first' API development?
- Writing frontend before backend
- Defining the API specification before writing any implementation code (Correct answer)
- Designing the database schema first
- Creating UI mockups before coding
Correct answer: Defining the API specification before writing any implementation code
Design-first API development writes the OpenAPI spec upfront, enabling parallel frontend and backend work and ensuring the contract is agreed upon before coding begins.
What is the OpenAPI Specification (OAS) primarily used for?