Documentation

Docs / Reference

Claim contract: OpenAPI generation

Task T029 (ADR 0081, Accepted). Rows OG-1..OG-99 are reserved for this table; the rows below are implemented by internal/openapi. The Go table openapi.Rows (internal/openapi/contract.go) lists the same rows in the same order with the same forms, and TestContractTable keeps the two 1:1: every value the generator can write in a listed group (refusal and conflict reasons, methods, scheme classes, not_read fields, auth attributes, shape states, kinds, schema types, stop reasons, user value keys and statuses, mount shadowing) is the form of exactly one row, and every row a shape item names in x-graphvein.shape.not_standard[].row exists here.

What the document is

Graphvein writes an OpenAPI 3.1 document from stored facts only: the route nodes of the HTTP route extractors (Express, FastAPI, Axum, net/http, chi, gin, Next.js; route extraction), their stored auth attributes (auth extraction), their stored request and response shape (route shape, rows SM-1..SM-29), the imported specs and their documents_route edges (OpenAPI import), and the repository's explorer.path_values in graphvein.yaml. It runs no code, reads no source file again and fetches nothing. A field no row names is never written (row D).

The document states what the code registers, not what a running server answers. Absence is not a claim: a missing parameters, requestBody, responses or security means "Graphvein did not read it", and the operation says so in x-graphvein.not_read (OG-41), never by an empty value that OpenAPI would read as "none". Only items of kind fact (a typed declaration the framework enforces at runtime) become standard OpenAPI fields; every other item stays in x-graphvein (OG-76, OG-77).

Imported specs are never merged into a generated document (OG-60). One function writes the document for the CLI (graphvein openapi), the server (GET /api/v0/openapi) and the UI download, so all three give the same bytes for one store state.

Claim contract

Row Field Forms Emitted when Refusal / unknown
OG-1 openapi openapi:3.1.1 always "3.1.1": 3.1 makes responses optional, so nothing is invented -
OG-2 info.title always "<repository> routes extracted by Graphvein" -
OG-3 info.version info.version:unversioned always "unversioned": Graphvein does not know the API's version a version from code is never guessed
OG-4 info.description always: a constant text saying the document lists registered routes from source and that an absent field means "not read" -
OG-5 servers only configured try-it environments (tryit): first the project environments of graphvein-project.yaml that give the member a base URL, then the repository's own tryit.environments, in file order, each {url: <base_url>, description: "configured try-it environment <name> (<label>)", x-graphvein: {environment, label, file, line}}; absent when none is configured. An environment's auth setting is never written an inferred base URL (Compose port, dev-server default, imported servers, a base URL suggestion not written to the configuration) is never a server
OG-6 paths always (may be {}) -
OG-7 components when OG-85 writes a schema or OG-31/OG-87 a security scheme -
OG-8 tags (root) never (no tag fact is stored) -
OG-9 root x-graphvein always: generator, contract_version, index (run id, finish time, extractor, commit; null when not indexed), repository, group (repository), scope (production), counts, unresolved, unrepresentable, conflicts, excluded_test, imported_specs, user_values, shape_errors -
OG-10 path key refused:unknown_resolution one non-test paths[] entry of a production route with a non-null template and resolution literal, constant or settings_default: the template, plus / when trailing_slash is true and the template is not / (ADR 0019) resolution: unresolved or no entry: OG-45 (unless OG-92 applies); another resolution value (not one this version reads): OG-46 unknown_resolution
OG-11 path key parameters refused:invalid_template, refused:duplicate_parameter_name the {name} segments, kept as stored (Express, gin and Axum :name, Next.js [name] already converted; Starlette convertors stripped) unbalanced braces, an empty name or one holding / or : (invalid_template); one name twice (duplicate_parameter_name): OG-46
OG-12 multi-segment wildcards refused:wildcard never: OpenAPI 3.1 path parameters match one segment {*}, {*name}, {name...}: OG-46
OG-13 optional parameters refused:optional_parameter never entry optional: true (Express :x?, Next.js [[...n]]): OG-46
OG-14 host-restricted patterns refused:host_pattern never route attribute host (net/http host patterns): OG-46
OG-15 equivalent templates conflict:equivalent_templates never for any of them: OpenAPI 3.1 "Path Templating" forbids two keys equal up to parameter names OG-47 with every key and route
OG-16 path item x-graphvein always: entries[] (route, method, resolution, conditional, assumptions) of every route giving the key -
OG-17 ANY routes method:ANY a route with method ANY (Express all, FastAPI with no methods, Axum any, chi/gin Any/Handle, net/http without method, Next.js Pages Router API) is listed in the path item's x-graphvein.any_method with its route, file and line never expanded into eight operations
OG-18 Starlette path convertor convertor:path a FastAPI {name:path} parameter of the route's own pattern is written as {name} (as FastAPI's own spec writes it) and its parameter's x-graphvein.matches says it matches any text, including an empty value and /, which an OpenAPI path parameter cannot express. A FastAPI parameter that comes from a router prefix gets x-graphvein.matches: "not read: ...": prefixes are stored composed, without their convertors -
OG-19 first-match shadowing first_match:express, first_match:fastapi Express (router stack in registration order) and Starlette (route list in inclusion order) dispatch a request to the first matching route. An operation of these frameworks lists in x-graphvein.may_be_shadowed every other route of the same framework, with the same method or ANY, whose path matches every request of the operation's path (a literal equals a literal, compared without case for Express, whose routing is case-insensitive unless caseSensitive is set, which is not read; {name} matches one non-empty segment; a final multi-segment parameter matches the rest: Starlette's {name:path} and Express 4's unnamed * also an empty rest, Express 5's {*name} one segment or more; Express ignores a trailing slash), each with order: "not_checked": whether it is registered earlier on the same router or app is not stored, so it may answer those requests first. Counted in counts.may_be_shadowed gin, chi, net/http, Axum and Next.js route by specificity (a literal segment wins over a parameter whatever the order): no list (not compared against those frameworks' routers)
OG-20 operations method:GET, method:PUT, method:POST, method:DELETE, method:OPTIONS, method:HEAD, method:PATCH, method:TRACE, refused:method_not_in_openapi_3_1, conflict:duplicate_operation OG-10 gives the key, the method is one of the eight, and exactly one production route has this key and method, or every route that has it is in one Express equivalent_registrations group (the group's first registration is written, as the matcher picks it, and the group is listed in x-graphvein.equivalent_registrations) another method (Axum CONNECT, an extension method): OG-46; two routes that are not one group (several registrations, several apps): OG-47 duplicate_operation, no operation: never one picked silently
OG-21 implicit methods never: an implicit HEAD for GET or an automatic OPTIONS is not written -
OG-22 operationId never: none is stored, and a Graphvein-made id would look like a declared one OG-41
OG-23 summary, description never OG-41
OG-24 tags (operation) never OG-41
OG-25 deprecated never -
OG-26 path parameters one per OG-11 name in template order: {name, in: path, required: true, schema: {}} with x-graphvein.type: "not_read"; schema: {} states no constraint, never a type a type comes only from OG-72
OG-27 query, header, cookie parameters without a shape never OG-41
OG-28 requestBody without a shape never OG-41
OG-29 responses without a shape never OG-41
OG-30 security from FastAPI dependencies the route's shape has no read security section, security_dependencies is non-empty, security_dependencies_unknown is empty, every entry's class has an OG-31 object and auto_error is literally true: one requirement naming every scheme (AND), scopes [] anything else: no security (OG-42 keeps the entries). security: [] is never written
OG-31 components.securitySchemes from FastAPI classes class:HTTPBearer, class:HTTPBasic, class:HTTPDigest, conflict:scheme_name_conflict HTTPBearer, HTTPBasic, HTTPDigest -> {type: http, scheme: bearer/basic/digest} under the stored scheme_name (a valid component name) OAuth2 classes (flows not stored), API key classes (key name not stored), OpenIdConnect (URL not stored), an entry with subclass (a repository subclass may override __call__): no scheme and no security. One name with two definitions in the document: neither is written and every operation using it loses its security (OG-47 scheme_name_conflict)
OG-32 operation x-graphvein always: route, file, line, framework, handler, handler_expression, rule, confidence (1), template, resolution, conditional, assumptions, documented_by, auth, not_read; equivalent_registrations, shape, shape_error when they apply -
OG-40 x-graphvein.rule always: the extraction rules of the route's framework (Express routes (ADR 0013, ...), FastAPI routes (ADR 0015, ADR 0019), Axum routes (ADR 0016), Go routes, GR rows (ADR 0076), Next.js routes, NX rows (ADR 0077); another framework is named as an external indexer's) -
OG-41 x-graphvein.not_read not_read:query, not_read:header, not_read:cookie, not_read:requestBody, not_read:responses, not_read:operationId, not_read:summary, not_read:tags, not_read:security, not_read:path_parameter_types always, in this order: query, header, cookie, requestBody, responses, path_parameter_types unless the shape's section (query, header, cookie, body, responses, path) is read (any state but not_read); operationId, summary, tags always; security unless a requirement is written or the shape's security section is read -
OG-42 x-graphvein.auth auth:security_dependencies, auth:security_dependencies_unknown, auth:middleware, auth:mounted_middleware, auth:mounted_middleware_unknown, auth:middleware_declares, auth:layers, auth:layers_unknown always: each of these route attributes present on the route, as stored an empty list means "none read", never "unauthenticated"
OG-43 x-graphvein.resolution, .conditional, .assumptions resolution:literal, resolution:constant, resolution:settings_default always: the entry's resolution (settings_default: the path holds a settings default the environment may override), conditional: true for an entry registered under a condition, and the assumptions ({id, from}: route for the route's own, path_entry for the entry's, such as GR-V5). Conditional and settings-default paths are in paths, marked -
OG-44 x-graphvein.documented_by always (may be []): every imported api_operation with a documents_route edge to the route: operation identity, its file, the edge confidence the committed operation is never merged (OG-60)
OG-45 root x-graphvein.unresolved[] unresolved:no_path, unresolved:unresolved_base, unknown:base_path, unknown:mount_or_prefix, resolution:unresolved every production route with no usable entry and no OG-92 value: route, method, pattern, file, line, reason no_path (no entry: unmounted, unresolved mount or prefix) or unresolved_base (entries with resolution: unresolved, a Next.js basePath that is not a literal; templates_after_base lists them), unknown naming the unknown part (base_path with the project, or mount_or_prefix, with the stored diagnostic and expression that names the registration when there is one), and keys: the explorer.path_values keys that would supply it -
OG-46 root x-graphvein.unrepresentable[] every OG-11..OG-14 and OG-20 method refusal: route, method, key, reason -
OG-47 root x-graphvein.conflicts[] every OG-15, OG-20 and OG-31 conflict: reason, keys, method, routes -
OG-48 root x-graphvein.excluded_test always: test-scope routes and test-scope path entries of production routes, counted and left out -
OG-49 root x-graphvein.counts always: routes, production routes, operations, path keys, ANY entries, unresolved, unrepresentable, conflicts, operations set by you, conditional, settings default, with a shape -
OG-50 grouping one document per repository: group: "repository"; each operation names its file, so the explorer can filter by component which app object serves a route is not stored, so one document can mix servers; servers names configured environments only (OG-5)
OG-51 ordering path keys in byte order; methods in OpenAPI's order; lists in x-graphvein by route identity. The document is deterministic for one store state -
OG-52 serialisation format:json, format:yaml JSON (UTF-8, two-space indent, LF, final newline) by default; YAML (--format yaml, format=yaml): the same document, keys in the same order -
OG-60 imported specs never merged. Root x-graphvein.imported_specs[] lists each api_spec (identity, file, title, spec version, scope, operation count and link statuses); operations carry OG-44 -
OG-61 project mode one document per member (the member's routes and the member's graphvein.yaml); cross-repository links are not written -
OG-70 shape attribute a route with a valid stored shape (SM-1) gets x-graphvein.shape (version, depth limit, sections, not_standard items, models, depth_cap chains, stop counts) and OG-71..OG-89 apply a shape that does not decode or breaks a model rule: x-graphvein.shape_error, counted in shape_errors, read as absent (OG-26..OG-30)
OG-71 section states state:not_read, state:provably_none, state:partial, state:complete each section's state as the code proves it, reason and evidence as stored, with the number of its items written as standard fields; a section that is not not_read leaves OG-41's list. A section whose items all come from a committed spec (route-shape-spec SH-O3) is not_read here and for OG-41, OG-30 and OG-87 (SH-O19): the document states what the code registers -
OG-72 path parameter types section:path a fact path item with access declared whose name is an OG-11 name: its schema (OG-83..OG-86) replaces {}, its provenance goes in the parameter's x-graphvein a non-fact path item: OG-76/OG-77
OG-73 fact path parameter not in the key never as a parameter kept in not_standard (OpenAPI requires every path parameter to be in the key)
OG-74 fact query, header, cookie parameters kind:fact, access:declared, section:query, section:header, section:cookie, presence:required, presence:optional a fact item with access declared and presence required or optional: {name, in, required: true/false, schema} (schema {} with x-graphvein.type: "not_read" when the type was not read), provenance in x-graphvein. The section may be partial: each written parameter is true, others may exist (OG-71 says so) -
OG-75 fact parameters OpenAPI would misread presence:unknown, header:accept, header:authorization, header:content-type never as a parameter presence unknown (OpenAPI reads a missing required as optional); a header named Accept, Content-Type or Authorization (OpenAPI ignores those): kept in not_standard
OG-76 names read in code kind:read_in_handler, access:read_by_handler, access:read_by_dependency never a standard field: kept in not_standard with presence unknown and no type, as stored -
OG-77 intended, returned and mapped items kind:intended, kind:returned, kind:mapped never a standard field, in any section: an intended or returned type is not checked at runtime, and a committed spec is shown beside the code, never merged (OG-60) kept in not_standard with its kind
OG-78 request body section:body fact items with a content type: requestBody.content[<type>] with the schema (or no schema and x-graphvein.schema: "not_read"), provenance in the media type's x-graphvein; requestBody.x-graphvein.required is "not_read" (the model has no body presence; OpenAPI's default false is not a claim Graphvein makes) -
OG-79 fact body without a content type never kept in not_standard: OpenAPI keys bodies by media type
OG-80 responses section:responses fact items with a content type: responses[<status>].content[<type>] with the schema (or x-graphvein.schema: "not_read"); description is "Not read by Graphvein" with x-graphvein.description: "not_read" (OpenAPI requires the field; Graphvein reads no prose) -
OG-81 proven empty response body a fact item whose schema is type null (not nullable) and whose content type is not stated: responses[<status>] with no content (an empty body) and x-graphvein.body: "none" -
OG-82 fact response body without a content type never kept in not_standard
OG-83 schema: scalar and array types type:string, type:number, type:integer, type:boolean, type:null, type:array, type:enum {type: ...}; array {type: array, items}; enum {enum: [...]} -
OG-84 schema: objects type:object, additional:allowed, additional:forbidden, additional:unknown {type: object, properties, required}: required lists fields of presence required; a field of presence unknown carries x-graphvein.presence: "unknown"; additionalProperties: false for forbidden, nothing for allowed, x-graphvein.additional: "unknown" for unknown -
OG-85 schema: models type:ref a reference to a model of kind fact whose models are all facts: $ref to components.schemas.<name> (the name with characters outside [A-Za-z0-9._-] as _); routes whose models share a name and a whole definition share one component, a different definition gets <name>_2, ...; each component's x-graphvein names the model and its provenance a reference that reaches a model of another kind: the item is kept in not_standard
OG-86 schema: unknown and nullable type:unknown, nullable:true unknown: {} with x-graphvein.unknown: <reason> (no constraint); nullable: type: [<type>, "null"], null added to an enum, anyOf: [<ref>, {type: null}] for a reference -
OG-87 security from the shape section:security, scheme:http, scheme:apiKey, scheme:openIdConnect, scheme:oauth2, scheme:unknown the section is complete, every alternative read from code is a fact (mapped alternatives from a committed spec are kept in not_standard, OG-77) and every scheme it names is a fact with its OpenAPI fields read (http: scheme, optional bearer format; apiKey: in and the key name; openIdConnect: the URL): security lists the alternatives (an anonymous alternative as {}), schemes in components.securitySchemes (OG-31's conflict rule applies). The shape's section replaces OG-30 when it is read partial (another alternative may exist), a non-fact alternative, oauth2 (the stored token URL does not say which flow), unknown, a detail not read: no security, items kept in not_standard
OG-88 provably none never written as an empty standard value: no security: [], no empty parameters the section's state and evidence are in x-graphvein.shape.sections; a proxy or middleware outside the code may still require auth
OG-89 call following stop:ended, stop:depth_cap, stop:cycle, stop:joined, stop:budget, stop:resolver_error, stop:unresolved, stop:ambiguous, stop:external, stop:transformed, stop:opaque_type x-graphvein.shape.stops counts the stored chains by stop; x-graphvein.shape.depth_cap lists the chains that stopped at the depth limit ("depth cap reached (N)": raise index.shape_depth) -
OG-90 user-supplied path values: keys key:route:, key:nextjs_base_path: explorer.path_values keys survive re-indexing: a route identity (route:<file>#<METHOD> <pattern>, stable while the file and registration stay) for the whole path of one route, or nextjs_base_path:<project directory> (. for the root) for a Next.js basePath read as not literal. A route identity can move to another registration of the file when a registration with the same method and pattern is added or removed above it (the @2 ordinals shift), so a route key's entry records registration (the route's stored content hash; the explorer's edit writes it for every route key); the value is used only while the hash matches, else it is unused with registration changed; a route whose registration text has a byte-identical twin in the same file (one hash for both) gets no value (unused, ambiguous registration; the edit refuses it); without a recorded hash the value is used and carries a warning -
OG-91 user-supplied path values: checks a registration, when given, is sha256: and 64 hex digits on a route key; a value is a path starting with / without spaces, control characters, ? or #; a route value's braces are {name} parameters (no /, *, : in the name); a base path has no braces and no trailing / (or is ""); keys are unique. graphvein.yaml with a value that breaks a check does not load -
OG-92 user-supplied path values: use resolution:set_by_you a route with no usable entry (OG-45) whose route key, or whose project's nextjs_base_path key (put before each unresolved template), has a value: its operations are built as OG-10..OG-89 with resolution: "set_by_you" and an assumption {id: "set_by_you", from: "graphvein.yaml explorer.path_values", key, value}. A route with a usable path read from code is never changed by a value, and a value never removes or displaces an operation read from code: a value whose key equals a code-read key with the same method, or equals a code-read key up to parameter names, is refused on its own (unused with the reason) and the code operation stays. The values change only this document, the explorer and try-it, never the index or other views -
OG-93 user-supplied path values: status user_value:used, user_value:unused root x-graphvein.user_values[]: every entry with its status, the operations using it and, for unused, why (no route without a path has the key; the route has a path read from code; its path conflicts with a code-read operation; registration changed; ambiguous registration); registration and warning for route keys (OG-90) -
OG-94 unresolved mounts: keys key:mount: a route the linker stores without a path because composition stopped at a hop it cannot read carries the route attribute unresolved_mounts (Go gin/chi/net/http: a chi Route/Mount, gin Group or net/http composition whose prefix or outer pattern is not a constant, a composition of a router argument no rule proves, a wrapped or escaped router; Express: a use whose prefix is not a constant; FastAPI: an include_router or mount prefix, or a router's own prefix=, that is not a constant, for a router something includes; Axum: a nest or nest_service whose prefix is not a constant, the nested router resolved (a nest_service hop's / is stored as both "" and /); its key text is <receiver>.nest(<prefix>), .nest(<prefix>) on a call chain, and its hash elides closure bodies and inline router chains among the arguments; value_covers is hop when the router the nest is called on has a path and is below no unknown hop and no trailing or doubled slash above, else root, never nothing): per hop, key (mount:<file>#<function> <hop call and first argument>, with @N for the Nth hop of the same text in the function, in source order), registration (a content hash of the file, function and the hop's whole text with function bodies elided and, when every router above the hop is proven, the composition above it: the known prefixes and hops from the root; it changes when the hop or the composition above it changes, not when routes below it change), reason (route_prefix_unresolved or route_mount_unresolved), hop, file, line, shadowing (OG-96), value_covers and paths, in the stored path entry form. value_covers: "hop": every router above the hop is proven; paths are composed through them with the hop's unread part left out, each carrying the known prefix above the hop in above (absent at the root). "nothing": the hop adds no unread part (a net/http Handle without StripPrefix whose outer pattern or router argument is not proven, a wrapped router passed to Handle); paths are the served paths. "root": a router above the hop is not proven (an escape, a wrapper not at a Handle, a hop below another unknown hop); paths are composed from the hop's router as from a root. The path "" below a hop is the prefix itself, distinct from /. The hop is the first one composition stops at walking up from the registration (a hop above an escaped or wrapped router is not passed); a route below several hops has one entry per hop (at most 16). A value for a mount key is a path as OG-91, without a trailing / unless it is /, and without an empty, . or .. segment; the explorer's edit records the hop's registration with it and refuses a key no stored route has, a hop with a byte-identical twin, or a value other than / for a hop whose value_covers is nothing. GET /api/v0/explorer/path-values lists the hops (mounts) with value_covers, the known prefixes above and the number of routes below each Next.js is not stored (it has OG-90's basePath key); Axum: a nest, nest_service or merge whose router argument no rule resolves (no route is linked below it), and the nested router's / path and the trailing-slash paths below the hop when the crate's axum version is not proven within 0.6.20 to 0.8.x (rows SH-X11, SH-X25; 0.6.20, 0.7.9 and 0.8.8 were checked) are not stored; a refused prefix (a pattern no row reads, an invalid chi prefix) is not a hop: a value cannot make it read
OG-95 unresolved mounts: use a route with no usable entry (OG-45) and no route key value (a route key comes first), with a hop whose key has a value: every non-test path below the hop becomes a candidate at above + value + path (above empty unless value_covers is hop; / adds nothing; the path "" below a hop is the prefix itself and / the prefix with trailing_slash, except for Express; an Axum nested router's / is stored as "": axum 0.6.20, 0.7.9 and 0.8.8 answer it at the prefix without the slash, and 404 with it), resolution: "set_by_you" and an assumption {id: "set_by_you", key, value, text} saying what you state: with hop, the part the hop adds after the prefix read above it; with nothing, that the hop passes requests on unchanged (a value other than / is unused, "the only value is /"); with root, the whole prefix from the root, the routers above the hop not being proven either (for a wrapper not proven path-preserving, such as miniflux's middleware chain, the value asserts that it passes the request through with prefix P); then OG-10..OG-89 apply as for any candidate, OG-92's rule included (a value never removes or displaces an operation read from code), and OG-19 is computed over the placed paths. An Express or FastAPI mount candidate refused against a code-read operation (OG-92) is still listed in that operation's may_be_shadowed when its path matches every request of it, with set_by_you naming the key: with the stated value it may answer those requests first. A hop below another unknown hop is a root hop: its value takes the outer part, and routes directly below the outer hop need the outer hop's value. A value is used only while its recorded registration equals the hop's (else unused, "registration changed"); a hop whose hash two keys share gets no value (unused, ambiguous hop); a value without a recorded hash is used with a warning -
OG-96 unresolved mounts: shadowing shadowing:not_checked an operation placed by a mount value below a Go or Axum hop carries x-graphvein.shadowing: "not_checked": the Go rows' checks above the hop (GR-C1's parent tree, GR-C3's sibling patterns, GR-C7's gate) need the hop's prefix and its parent router, which are not read, so a sibling registration may answer some of the paths first; for Axum the routes and nests beside the hop on the parent router are not compared with the placed paths. Express and FastAPI hops are checked by OG-19 over the placed paths -
D everything else nothing: no field, no default, no guess. Every OpenAPI field not in a row above is absent; where its absence could be read as "none" (parameters, bodies, responses, security) OG-41 names it not_read -

Path normalisation agreements (checked against references)

Stored templates follow route extraction ("Exact template normalization"). The generator's corpus check compares the generated documents' paths and methods with committed references (the T029 task record (internal) has the counts): FastAPI's own generated client for full-stack-fastapi-template, the realworld spec for Express, Axum and gin, gotify's, seerr's, owncast's and langflow's committed specs. No generated operation contradicts a reference on path or method; parameter names differ where the code and a hand-written spec differ, and the code's names are written.

Validation

Every generated document of the golden fixtures and of the corpus check is validated against the OpenAPI 3.1 JSON Schema with a pinned validator (@seriousme/openapi-schema-validator 2.11.0, MIT) installed outside the repository, and every Schema Object in it is compiled as JSON Schema 2020-12 (Ajv); the validator is a test-only oracle, never a dependency of the binary.

Report a problem with this pageSource: docs/contract/claims/openapi-generation.md