DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Why Your OpenAPI Spec Sucks

2 years ago thenewstack.io

Summary: This is a summary of an article originally published by The New Stack. Read the full original article here →

A mix of anticipation and dread washes over me as I open a new inbound email with an attached specification file. The API request bodies lack essential details: the actual properties of the HTTP call, making it impossible to determine expectations and behavior.

59 openapi: 3.0.0 info: title: Nested Query Example version: 1.0.0 paths: /users: get: summary: Get users with nested query parameters parameters: - name: filter in: query schema: type: object properties: name: type: string age: type: number address: type: object properties: city: type: string state: type: string country: type: string zipcode: type: string

Let’s look at this example: 1 openapi: 3.0.0 info: title: Sample API version: 1.0.0 paths: /data: post: summary: Upload user data requestBody: required: true content: application/json: schema: type: object properties: name: type: string age: type: integer email: type: string responses: '200': description: Successful response

You rush to add an example to your OpenAPI spec: parameters: - name: id in: path required: true schema: type: string example: e4bb1afb-4a4f-4dd6-8be0-e615d233185b description: The user id.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com