API / Swagger Interview questions
Define paths in an OpenAPI document?
The paths object is the section of an OpenAPI document that enumerates every available endpoint (URL template) in the API, and for each one, which HTTP methods (operations) it supports.
paths: /users/{userId}: get: summary: Get a user by ID parameters: - name: userId in: path required: true schema: type: integer responses: '200': description: A user object
Each key under paths is a URL template, which may include path parameters in curly braces like {userId} above, and each key nested under that path (get, post, put, delete, and so on) describes one operation available at that path, including its parameters, request body, and possible responses.
This structure is what a tool like Swagger UI reads to build its list of endpoints, and it's also the primary thing code generators traverse to produce one method per operation in a generated client SDK.
More Related questions...