Start from what you have
Your API already has an OpenAPI 3.0, 3.1 or 3.2 description, in JSON or YAML, in a file or at a URL. That is all it needs. It never calls the API.
Tools · Build an API · v0.2.0
restep-from-openapiFrom OpenAPI to RestepReads the OpenAPI 3 you already have and tells you, profile by profile, what keeps it from Restep. Then writes a first discovery document, marking what it guessed.
Node 18 or later · npx restep-from-openapi
Your API already has an OpenAPI 3.0, 3.1 or 3.2 description, in JSON or YAML, in a file or at a URL. That is all it needs. It never calls the API.
Each finding names its section of the specification, the operations where it shows (GET /pets?page, schema Pet.id) and what to do instead, profile by profile.
It drafts the document of 4.2 from your paths and schemas, valid against discovery.json, and marks every guess with how sure it is.
A score per profile, from 0 to 100, to compare APIs and follow your progress from one pull request to the next.
$refs resolved.POST with 201) or has items (/x/{id}).An error breaks a MUST the description lets it see; a warning is a MUST that probably fails, or a SHOULD; a note is advice. What the description does not document (an ETag, the error codes) counts as absent. To check a running server, use restep-check.
npx restep-from-openapi openapi.yaml
npm install -g restep-from-openapi # to keep it
Node 18 or later, no dependencies: the package carries its own YAML and JSON Schema modules. To validate the draft it uses the copy of discovery.json in its schema/ folder or, failing that, fetches it from this site; with neither, the report says the draft was not validated.
The report is in Spanish for now. Finding ids (core.put, query.pagination.offset) and the links to each section are the same in both languages.
A Petstore with the usual vices: page numbers, bare arrays, PUT, JSON Patch, its own errors, numeric ids, verbs in URLs.
$ npx restep-from-openapi petstore.yaml --report gaps.md --out discovery.json
Petstore ampliada: 3 colecciones, 33 hallazgos.
core 0 mucho trabajo
query 29 mucho trabajo
writes 65 trabajo moderado
cache — ninguna lectura documenta Cache-Control
relations 86 trabajo moderado
sync — sin indicios de sincronización en la descripción
Informe: gaps.md
Descubrimiento: discovery.json
Markdown, one heading per profile, with what is missing and what already complies. An excerpt:
## core (obligatorio)
### Lo que falta
- **Error: El identificador es un número.** [§3](https://restep.wubytes.com/es/1/#datos) `data.id.type`
El id es una cadena ("7"), siempre: así se puede cambiar de generador de ids sin romper a los clientes.
Dónde: `/pets/{petId} ({petId}: integer)`, `esquema Pet.id (integer)`.
…
- **Error: Usa PUT para actualizar.** [§5.1](https://restep.wubytes.com/es/1/#recursos) `core.put`
PUT queda fuera de Restep 1: ofrece PATCH con JSON Merge Patch (application/merge-patch+json), donde lo ausente no se toca.
Dónde: `PUT /pets/{petId}`.
…
## query
### Lo que falta
…
- **Aviso: Un filtro sobre un campo que es una lista.** [§6.1](https://restep.wubytes.com/es/1/#filtros) `query.filter.list`
Restep 1 no declara en filter un campo cuyo valor es una lista (§6.1). El borrador lo declara como filtro con nombre (named_filters), que se usa con filter[campo]=valor sin operadores y cuyo significado lo da su descripción.
Dónde: `GET /pets?tags → filter[tags]`.
- **Aviso: Los filtros usan nombres propios, no filter[campo][op].** [§6.1](https://restep.wubytes.com/es/1/#filtros) `query.filter.name`
Pasa cada filtro a filter[campo] o filter[campo][op] y declara campo, tipo y operadores en filter: así un filtro que el servidor no conoce da 400 en vez de devolver la colección entera.
Dónde: `GET /orders?customer_id → filter[customer_id]`, `GET /orders?created_after → filter[created_at][gt]`, `GET /pets?status → filter[status]`, `GET /pets?tags → filter[tags]`, `GET /pets?min_price → filter[price][ge]`, `GET /pets?max_price → filter[price][le]`.
…
The pets collection, with --no-schemas to keep it short. min_price and max_price became one price filter, tags (a list) and the free text q became named filters whose description you have to review, PUT became PATCH, and POST /pets/{petId}/adopt became an action. The draft declares "restep": "1.0-draft.6", the text the tool follows:
"pets": {
"path": "/pets",
"description": "Lista las mascotas a la venta.",
"methods": ["GET", "POST"],
"item_methods": ["GET", "PATCH", "DELETE"],
"filter": {
"status": { "type": "enum", "values": ["available", "pending", "sold"], "ops": ["eq"] },
"price": { "type": "decimal", "ops": ["ge", "le"], "x-confidence": "medium",
"x-source": "GET /pets?min_price; GET /pets?max_price" }
},
"named_filters": {
"tags": { "type": "string",
"description": "Elementos cuyo campo tags, una lista, contiene el valor (deducido de tags: revisa el criterio).",
"x-confidence": "low", "x-source": "GET /pets?tags" },
"q": { "type": "string",
"description": "Búsqueda de texto libre (deducida de ?q: describe qué campos mira y cómo compara).",
"x-confidence": "low", "x-source": "GET /pets?q" }
},
"sort": ["name", "price", "createdAt"],
"max_limit": 100,
"actions": {
"adopt": { "on": "item", "safe": false, "idempotent": false, "description": "Adopta la mascota.",
"x-confidence": "low", "x-source": "POST /pets/{petId}/adopt → POST /pets/{petId}:adopt" }
},
"x-restep-from-openapi": {
"confidence": "high", "source": "GET /pets, GET /pets/{petId}",
"notes": ["item_methods: PATCH sale del PUT, que Restep no admite",
"actions.adopt: idempotent false es una suposición"]
}
}
The x- members are allowed by the specification, so the draft validates as it is; but they are for you to review, then remove (or ask for none with --no-annotations).
$ npx restep-from-openapi casi-restep.json
…
| core | 100/100 | 0 | 0 | casi listo |
| query | 100/100 | 0 | 0 | casi listo |
| writes | 100/100 | 0 | 0 | casi listo |
| cache | 100/100 | 0 | 0 | casi listo |
| relations | 100/100 | 0 | 0 | casi listo |
| sync | — | 0 | 0 | sin indicios de sincronización en la descripción |
problem+json, Merge Patch, ETag, If-Match, Idempotency-Key, filter[…], a subcollection, an action :reserve, Cache-Control on every read and OAuth 2.0. Next step: restep-check against the running server.
$ npx restep-from-openapi petstore.yaml --json | jq -c '.scores.core, .findings[0]'
{"score":0,"errors":8,"warnings":7,"note":"mucho trabajo"}
{"id":"data.id.type","profile":"core","severity":"error","section":"3","title":"El identificador es un número.","fix":"El id es una cadena (\"7\"), siempre: así se puede cambiar de generador de ids sin romper a los clientes.","where":["/pets/{petId} ({petId}: integer)","esquema Pet.id (integer)"]}
The JSON carries tool, api, collections, scores, findings, passes, unresolvedRefs, lowConfidence, discovery and validation.
| Option | What it does |
|---|---|
<openapi.json | openapi.yaml | URL> | The OpenAPI 3 description |
--out file | Writes the draft discovery document (JSON) |
--report file | Writes the report in Markdown, and only the score summary goes to stdout. Without it, the whole report goes to stdout |
--json | The whole result as JSON on stdout, instead of the report |
--no-schemas | Does not copy the OpenAPI schemas into schemas or into the input of actions: a much shorter draft |
--no-annotations | Without the x-confidence, x-source and x-restep-from-openapi members |
--help | The help |
It exits with 0 when it worked, findings or not; 1 when it cannot read the description; 2 on a usage error. If the draft did not validate against the schema, it says so on stderr.
| Profile | Findings |
|---|---|
core | A POST body to a collection or an action that is not application/json (forms, multipart) (3); lists as bare arrays, without items or next (5.2); PUT, PATCH without Merge Patch or with JSON Patch, a creating POST without 201 or Location, POST on an item, DELETE without 204, RPC-style paths such as /getContacts (5.1); a create body that takes id, which becomes id_from (note, 5.1); single-object resources that become singletons, and resources outside Restep (notes, 5.9); deprecated operations, parameters or fields (note, 5.5); $ parameters and reserved ones used with another meaning (since as a date, sort=asc) (5.3); errors that are not problem+json, problem+json without code, success or ok in a 200 (5.4); versions in a header, the query or the media type, or /v1.2/ (5.5); numeric or missing ids, fields starting with _, 64-bit integers, amounts as numbers, instants as numbers or without a format, camelCase mixed with snake_case (3) |
query | Paging by offset or page, a cursor by another name, page_size or per_page instead of limit, limit without a maximum, which draft 6 requires to be declared (6.4); filters with names of their own (status, min_price, created_after), with their translation to filter[price][ge] (6.1); filters on a field that is a list (tags), which become named filters, or that go through one (6.1); sort_by and order (6.2); select (6.3); include_total (6.5); searches on their own path (/pets/findByStatus) and free text q, which becomes a named filter (note) |
writes | No ETag on the item’s GET, no If-Match or 412 on PATCH, PUT or DELETE (7.2); POST without Idempotency-Key or with another name such as X-Idempotency-Key (7.1) |
cache | Undocumented Cache-Control on reads (note, 8). Since draft 6 it is a profile apart from writes; if no read documents Cache-Control, it is not scored |
relations | Relations as a bare id (owner_id) or a list of ids (pet_ids) (3); expand or embed instead of include (9) |
sync | Parameters such as modified_since, /changes or /delta paths, webhooks; if there are any, the missing :changes and state (10). Without a hint of sync, it is not scored |
| Extensions | Verbs in URLs that should be actions with a colon (11.1); /bulk and /batch (11.2); filter as a string (11.3); searches by POST (11.4); OAuth 2.0, to announce oauth, and credentials in the query (11.5) |
In the draft, the root is servers[0].url plus the common prefix of the paths when it ends in a version (/api/v2), which also gives "version". Subcollections such as /books/{id}/reviews keep the template in path, name in parent the collection they hang from, and are also declared as a to-many relation of their parent; repeated template variables are renamed (/authors/{id}/books/{book_id}/reviews, 4.2). A path without variables whose GET returns one object and that takes only GET, PATCH or PUT (which becomes PATCH), such as /me or /settings, becomes a singleton (5.9). A create body that takes an id without readOnly gives id_from: "client" if it is required, "either" if not (5.1). Following 6.1, it declares no order operators on id, nothing but eq, ne and null on a boolean, and no filter or sort on a list, through a to-many relation or up to the id of a subcollection’s item. Profiles: cache only if every read documents Cache-Control and every item GET an ETag; no experimental part (1.2). owner_id becomes the relation owner when there is an owners collection. count is exact when the list carries a total; status comes from /health, /status or similar.
$refs, nor callbacks or links; it notes them in the report.inherit (11.6) from any other object: OpenAPI does not distinguish them.collations (6.1), idempotency.anonymous (7.1), deprecations (5.5: the announced instant is missing, so deprecated only comes out as a note), sync (10) or any other experimental part, or an estimated count.415 to other media types, + read as a space, _etag on every item, the origin 403 (5.8)…x- extensions (such as x-pagination) and examples.GET go into the draft with low confidence. A single resource with POST or DELETE, or under a collection’s path, is left outside Restep, with a note.? ), no tabs in indentation. If yours does not parse, convert it: yq -o=json openapi.yaml > openapi.json.npx swagger2openapi swagger.json -o openapi.json.A server library that does the hard part: discovery, query, errors, ETags, idempotency. You write the data access. Node, Express, Hono or fetch.
A fake API from a discovery document, with plausible data, subcollections and actions. Filters, pages and fails like the real one, so the front end starts today.