slogan3

Maak een OpenAPI Specificatie voor API Foutafhandeling en Responsstandaarden

description

Met deze prompt kan de gebruiker een OpenAPI specificatie maken die duidelijke richtlijnen biedt voor foutafhandeling en response formaten, wat integratiefouten vermindert en de ontwikkelaarservaring verbetert. Het helpt bij het standaardiseren van API reacties, waardoor API's betrouwbaarder en makkelijker te gebruiken zijn.

prompt

Help me een OpenAPI specificatie te maken die duidelijk de foutafhandelingsmechanismen en standaard responsstructuren beschrijft voor mijn API. API Naam: <voer de naam van mijn API in> Foutcodes en Betekenissen: <beschrijf welke HTTP-foutcodes gebruikt worden en wat ze betekenen> Standaar ...

try_prompt

generate_helper
disclaimerOnPageApi

ai_answers

provider: openai
model: gpt-4.1-nano
openapi: 3.0.3 info: title: E-commerce API description: > API voor e-commerce platform met duidelijke foutafhandelingsmechanismen en standaard responsestructuren. version: 1.0.0 servers: - url: https://api.example.com/v1 components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-API-Key responses: SuccessResponse: description: Succesvolle respons content: application/json: schema: type: object properties: data: type: array items: type: object description: "Een item in de data array" ErrorResponse: description: Foutmelding content: application/json: schema: type: object properties: errorCode: type: string description: Foutcode (bijv. 400, 401, 404, 500) message: type: string description: Gedetailleerde foutboodschap security: - ApiKeyAuth: [] paths: /producten: get: summary: "Lijst van producten" security: - ApiKeyAuth: [] responses: '200': $ref: '#/components/responses/SuccessResponse' '400': $ref: '#/components/responses/ErrorResponse' '401': $ref: '#/components/responses/ErrorResponse' '404': $ref: '#/components/responses/ErrorResponse' '500': $ref: '#/components/responses/ErrorResponse' description: > Haal een lijst van producten op. Mogelijke foutcodes: - 400: Ongeldige aanvraag - 401: Niet geautoriseerd - 404: Niet gevonden - 500: Serverfout De standaard response voor fouten bevat een errorCode en message. /producten/{id}: get: summary: "Specifiek product op ID" security: - ApiKeyAuth: [] parameters: - name: id in: path required: true schema: type: string description: "ID van het product" responses: '200': $ref: '#/components/responses/SuccessResponse' '400': $ref: '#/components/responses/ErrorResponse' '401': $ref: '#/components/responses/ErrorResponse' '404': $ref: '#/components/responses/ErrorResponse' '500': $ref: '#/components/responses/ErrorResponse' description: > Haal details op van een specifiek product. Mogelijke foutcodes zoals hierboven. # Uitleg # Deze specificatie definieert: # - Standaard response structuren voor successen en fouten. # - Foutcodes en hun betekenissen. # - Authenticatie via API key. # - Consistente foutafhandeling via referenties naar errorResponse. # Dit maakt de foutmechanismen en response-structuren helder en herbruikbaar.
provider: deepseek
model: deepseek-chat
```yaml openapi: 3.0.3 info: title: E-commerce API description: API voor e-commerce functionaliteiten met gestandaardiseerde foutafhandeling version: 1.0.0 servers: - url: https://api.ecommerce.example.com/v1 description: Productieserver components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-API-Key description: API key voor authenticatie schemas: SuccessResponse: type: object properties: data: type: array items: {} description: Array met succesvolle respons data required: - data ErrorResponse: type: object properties: errorCode: type: string description: HTTP foutcode example: "400" message: type: string description: Beschrijvende foutmelding example: "Ongeldige aanvraag" required: - errorCode - message responses: Success: description: Succesvolle operatie content: application/json: schema: $ref: '#/components/schemas/SuccessResponse' BadRequest: description: Ongeldige aanvraag content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: invalidRequest: summary: Ongeldige aanvraag value: errorCode: "400" message: "Ongeldige aanvraag" Unauthorized: description: Niet geautoriseerd content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: unauthorized: summary: Niet geautoriseerd value: errorCode: "401" message: "Niet geautoriseerd" NotFound: description: Resource niet gevonden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: notFound: summary: Niet gevonden value: errorCode: "404" message: "Niet gevonden" InternalServerError: description: Serverfout content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: serverError: summary: Serverfout value: errorCode: "500" message: "Serverfout" security: - ApiKeyAuth: [] paths: /products: get: summary: Haal producten op description: Haal een lijst met producten op responses: '200': $ref: '#/components/responses/Success' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalServerError' /products/{id}: get: summary: Haal specifiek product op description: Haal een specifiek product op basis van ID parameters: - name: id in: path required: true schema: type: string description: Product ID responses: '200': $ref: '#/components/responses/Success' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalServerError' /orders: post: summary: Maak nieuwe bestelling description: Maak een nieuwe bestelling aan requestBody: required: true content: application/json: schema: type: object properties: productId: type: string quantity: type: integer required: - productId - quantity responses: '200': $ref: '#/components/responses/Success' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '500': $ref: '#/components/responses/InternalServerError' ``` Deze OpenAPI specificatie bevat: **Authenticatie:** - API key authenticatie via `X-API-Key` header **Standaard response structuren:** - Succes: `{"data": [...]}` - Fout: `{"errorCode": "400", "message": "Ongeldige aanvraag"}` **Foutafhandeling:** - 400 - Ongeldige aanvraag - 401 - Niet geautoriseerd - 404 - Niet gevonden - 500 - Serverfout **Herbruikbare componenten:** - Gestandaardiseerde success en error responses - Duidelijke voorbeelden voor elke foutcode - Toepasbaar op alle API endpoints De specificatie is modulair opgebouwd met herbruikbare componenten, wat consistentie garandeert en onderhoud vereenvoudigt.