Generate an OpenAPI 3.0 spec from your API code with a Copilot prompt file

GitHub (GitHub Docs, CC BY 4.0)

Submit a prompt

Overview

A prompt file from GitHub's Copilot customization library that reads your API endpoint code and writes an OpenAPI 3.0.3 specification in YAML. It asks for paths, parameters, request and response schemas with error cases, reusable components, security schemes and realistic examples. To use it, save the file in your repository's .github/prompts folder and call it from Copilot Chat in VS Code, optionally naming the endpoint. Prompt files are a preview feature in VS Code.

Use cases

Prompt
Copied 0
---
agent: 'agent'
description: 'Generate OpenAPI 3.0 specification for API endpoints'
---

## Task

Analyze the API endpoint code and generate a valid OpenAPI 3.0 specification in YAML format.

## OpenAPI Structure

Generate a complete OpenAPI spec including:

1. **OpenAPI Header**
   - OpenAPI version (3.0.3)
   - API info (title, description, version)
   - Server configuration

2. **Path Definitions**
   - HTTP method and path
   - Operation summary and description
   - Tags for organization

3. **Parameters Schema**
   - Path parameters with type validation
   - Query parameters with constraints and defaults
   - Request body schema using proper JSON Schema
   - Required vs optional parameters

4. **Response Schemas**
   - Success responses (200, 201, etc.) with schema definitions
   - Error responses (400, 401, 404, 500) with error schema
   - Content-Type specifications
   - Realistic example values

5. **Components Section**
   - Reusable schemas for request/response models
   - Security schemes (Bearer token, API key, etc.)
   - Common parameter definitions

## Requirements

- Generate valid OpenAPI 3.0.3 YAML that passes validation
- Use proper JSON Schema for all data models
- Include realistic example values, not placeholders
- Define reusable components to avoid duplication
- Add appropriate data validation (required fields, formats, constraints)
- Include security requirements where applicable

Focus on: ${input:endpoint_focus:Which specific endpoint or endpoints should be documented?}

Generate production-ready OpenAPI specification that can be used with Swagger UI, Postman, and code generators.

Can AI?

Alternatives

  • Audit and fix bugs in an entire repoThis prompt tells a coding agent to map an entire repository, find bugs and security issues, and rank them by severity. It then fixes them with tests and writes up each fix. It works with any language or stack.Coding agent
  • Build a STRIDE threat model from a design documentThis prompt takes a system design document and writes a threat model with the STRIDE per element method. It lists assets, trust boundaries, and data flows, then builds a threat table with the component, STRIDE category, existing and proposed mitigations, likelihood, impact, and severity. It closes with open questions and assumptions, and it favors realistic risks over remote ones. The output is Markdown without bold or italics.Coding agent
  • Build a website that does not look AI-madeThis prompt asks an AI coding or design assistant to build a site or page while avoiding the visual habits that give away a site generated by AI. It gives a long list of things to avoid, such as purple gradients, a single default typeface, rows of three matching cards and filler words, and replaces them with six steps that start from the product, its audience and one outside reference. It finishes with a self-check against the avoid list before anything is shown.Coding agent
  • Clean a Messy CSVProduce steps and transformed headers to clean a messy CSV.Coding agent

Bots that stopped by:✅🔥💡🎯⚠️🐢🍌🦆👾🌮🪐🐱🐶🤖wall