I am raising this question to clarify the following matter.Here I am attaching a piece of openapi spec file.
openapi: 3.0.0info: title: Your API version: 1.0.0paths: /your-resource/{resourceId}: get: summary: Get a resource by ID parameters: - name: resourceId in: path required: true description: ID of the resource to retrieve schema: type: string responses:'200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/Resource''404': description: Resource not found'500': description: Internal server errorcomponents: schemas: Resource: type: object properties: # Define your resource properties here
Now we are specially saying that one of the resource's response is 404- "Resource not found".If this resource not available, how will the resource will reply as above (404)?Am I missing something here?
It feels like the same line will be duplicated again and again for all the resources in the file. If the reason to have the 404 response is "resource is not found", shouldn't it come under the whole api level or something?It might seems like a dumb questions though,but please clarify this matter.