Chapter 09 of 10
What You Derive From OpenAPI
Reference documentation, mock servers, contract tests, monitors and code samples all come out of the same document. What each one needs from it, and where generation stops being useful.
The argument for writing a contract is not that the file itself is valuable. It is that several other things stop being written by hand once it exists.
Reference documentation
The most direct derivation. Every operation, parameter, response and schema in the document becomes a page or a section, complete by construction because it is a projection rather than a copy.
What the generator needs from you is the prose, since summaries, descriptions, enum meanings and error explanations are the parts no tool can invent. The API documentation guide covers what to write and what the generated layer cannot do for you.
Mock servers
A mock answers calls against the documented contract before the implementation exists, which is what lets a frontend start on the day the design is agreed rather than on the day the backend ships.
Response schemas do the work. A generator builds one rule per documented response, and fills each field from its type and format, so a date-time produces a timestamp and a field named email produces something that looks like one. Where the document says less, the mock returns less, which makes the quality of the mock an unusually honest measure of the quality of the schemas.
What a generator can read out of a schema, what it can never know, and how to make the result behave like a real network are covered in the API mocking guide.
Contract tests
A test that asserts the live API still matches the document can be derived, because the document states what to assert. The status code exists, the response validates against its schema, the required fields are present, the types are right.
What cannot be derived is everything the contract never described. Whether the total equals the sum of the line items, whether a cancelled order can be paid, whether three calls in sequence leave the system consistent. Those are business rules, and contract testing against integration testing covers where the line falls.
Monitors
The same validation that runs in a test run can run on a schedule against production, which turns a monitor from an uptime check into a continuous contract check.
The difference in what you learn is large. An uptime monitor tells you the endpoint answered, while a monitor validating against the schema tells you it answered with what you documented. The second one is how a field quietly dropped in a deploy surfaces in minutes rather than in a consumer's bug report.
Code samples
A request sample in cURL and in the languages your consumers use is mechanical, since the document already holds the method, the URL, the parameters, the headers and a body example.
Generated samples have one advantage over written ones that is easy to underrate. They cannot go stale, because they are rebuilt from the document every time the reference is published.
Where generation stops
Two limits are worth stating plainly rather than discovering.
Generated client libraries are shaped by the document. Generators exist and they work, and what they produce inherits every gap in the input. Untyped objects produce dictionaries, missing operation identifiers produce method names built from the path, and absent enums produce strings. The fix is upstream every time.
A contract describes one style of API. OpenAPI describes HTTP APIs. Event-driven systems have AsyncAPI and GraphQL has its own schema language, and a document for one of those is not an OpenAPI document. Versioning GraphQL, gRPC and events covers what changes when the protocol does.
In Routebase
The derivations above are features of the workspace rather than separate tools, and they all read the same specification. The API-first development page walks through that workflow from the reviewed contract to the environment that reports what it runs.
Documentation portals take their API reference from a published specification version. Mock rules are generated from a specification with one action, and a rule generated from a draft keeps projecting the current schema until you take ownership of it. Test cases are created in bulk from specification endpoints with their contract assertions already attached. Monitors are generated per endpoint from a specification and linked to it, which is what lets every check validate the response against the schema.

Code samples in the published portal cover cURL, HTTPie, JavaScript, Python, C#, Go, Java, Ruby and PHP, and which of them appear is a setting. Client SDK and server stub generation is not part of the product, and the export is a complete OpenAPI document, so the generator you already run keeps working on it unchanged.
Frequently asked questions
What can you generate from an OpenAPI file?
Reference documentation, a mock server, contract tests, uptime and schema monitors, request samples in several languages, and client or server code. Each of those reads the same document, so the quality of all of them is decided by how complete the document is rather than by the tool that reads it.
Can you generate a mock server from OpenAPI?
Yes, and the response schemas are what make it worth anything. A generator builds a response for each documented status code and fills the fields from their types and formats, so a field described as a date-time produces a plausible timestamp. An operation whose response is an untyped object produces an empty mock, which is the clearest signal that a schema needs work.
Can OpenAPI replace writing tests?
It replaces one kind of test rather than all of them. Contract assertions, meaning status code, response shape, required fields and types, can be derived from the document because the document states them. Whether the totals add up, whether the state machine allows a transition and whether a workflow across three calls holds together are business rules the contract never described.
Does OpenAPI generate SDKs?
The specification does not generate anything, and several generators produce client libraries from a document. What comes out is shaped by what went in, so a document with named schemas, enums and operation identifiers produces usable types, while one built from untyped objects produces a client that returns dictionaries.
Last reviewed by The Routebase Team.