How to use the OpenAPI generator
- Fill in API title, Version and Description.
- Enter the Server URL, the base address every path is added to. Leave it blank to omit
servers. - In Endpoints, write one per line: method, path, then a short summary, for example
PATCH /books/{id} Update a book. - Keep Bearer token authentication ticked if your API expects an
Authorization: Bearer …header. - Choose Format, YAML or JSON, and save the file as
openapi.yamloropenapi.json.
What it does and when to use it
Starting an OpenAPI file by hand means a lot of nested boilerplate before you describe anything useful. This tool writes that structure from a simple endpoint list. Use it when planning a new API, documenting an existing one that has no spec, or giving a frontend team something to mock against.
The skeleton is a start, not the finished contract. Draft the payload schemas with the JSON Schema generator, switch formats later with JSON to YAML, and tidy hand edits with the YAML formatter.
How it works
Each line is matched as METHOD /path summary. For every endpoint the tool adds:
- an
operationIdmade from the method and path words, such asgetBooksById; - a tag taken from the first fixed path segment (
books,orders); - a
requestBodyfor POST, PUT and PATCH; - a success response: 201 for POST, 204 for DELETE, 200 otherwise. A GET without path parameters returns an array;
- a 404 response when the path has parameters, and a 401 when bearer auth is on.
With bearer auth, components.securitySchemes gets an HTTP bearer scheme (format JWT) applied to the whole API. The structure follows the OpenAPI 3.1.0 specification.
Worked examples
The bookshop sample. Six endpoints produce /books, /books/{id} and /orders/{orderId}. Part of the YAML:
/books/{id}:
get:
summary: Get a book
operationId: getBooksById
tags:
- books
parameters:
- name: id
in: path
required: true
A small notes API as JSON. Four lines, bearer off. DELETE /notes/:noteId becomes /notes/{noteId} with "operationId": "deleteNotesByNoteId" and a 204 response. The line “fetch everything” is not an endpoint, so the tool reports it as skipped.
No valid lines. “list all books” alone gives the message “Add endpoints as “METHOD /path summary”, e.g. GET /users List users.”
Limits and tips
- Query parameters, headers, examples and error bodies are not generated; add them yourself.
- Path parameters are always typed as strings. Change them to
integerwhere that is true. - Rename any
operationIdyou do not like before generating client code, because generators use it for method names.
Frequently asked questions
Is the output OpenAPI 3.0 or 3.1?
Can I use Express-style paths like /users/:id?
Which HTTP methods are accepted?
Why do all my request and response bodies say type object?
Can I open the result in Swagger UI or Redoc?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.