/** * OpenAPI / Swagger reader (change: add-service-contract-certification, OpenAPI phase). * * Reads an OpenAPI 3.0/3.1 or Swagger 2.0 document (YAML or JSON) into a normalized element model: * one entry per operation, with its parameters, request body properties, and success-response * properties. Only local `$ref`s (`#/...`) are followed; anything the model does not read (external * or unresolved refs, callbacks, webhooks) is listed as unassessed, never dropped silently. * * Each element also carries a `hash` of everything about it the rule table does NOT compare * (constraints, nested schemas, composition, media types), so a difference there is seen and * reported as unassessed, never read as "no change". Hashes are Merkle hashes over the canonical * schema (keys sorted, documentation dropped, `required`/`enum`/`type` lists as sets): a reference to * an acyclic schema hashes the same as the schema written inline, and a schema in a reference cycle * hashes as the set of everything it reaches. No hash depends on the order operations are read. * Deterministic and offline: plain YAML/JSON parsing, no grammar, no network. */ export declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"]; /** Bytes of a specification read at most. */ export declare const MAX_SPEC_BYTES: number; export interface ContractParam { name: string; in: string; required: boolean; type?: string; hash: string; } export interface ContractProperty { name: string; required: boolean; type?: string; hash: string; } export interface ContractOperation { /** `GET /v1/orders/{id}`: the method and the full path template, servers base path included. */ address: string; /** The address with path-parameter names erased (`GET /v1/orders/{}`): the matching key. */ key: string; method: string; /** The path template with the base path, as written (`/v1/orders/{id}`). */ path: string; /** The path as declared under `paths` (without the base path). */ declaredPath: string; operationId?: string; line: number; deprecated: boolean; params: ContractParam[]; /** `undefined` when the operation takes no body. */ body?: { required: boolean; properties: ContractProperty[]; assessed: boolean; hash: string; }; /** Top-level properties of the 2xx JSON response, when it is an object schema. */ response?: { properties: ContractProperty[]; assessed: boolean; hash: string; }; /** The named schemas this operation references directly, deduplicated and sorted. */ refs: string[]; } /** * A named schema the document declares (`components/schemas/Order`, or Swagger 2's * `definitions/Order`) — a reusable TYPE, as opposed to an inline one * (change: add-contract-graph-projection). */ export interface ContractSchema { /** The JSON pointer that names it: `#/components/schemas/Order`. */ ref: string; /** The last segment: `Order`. */ name: string; line: number; /** The local refs its own definition makes directly, deduplicated and sorted. */ refs: string[]; } export interface ContractDocument { file: string; format: 'openapi-3' | 'swagger-2'; basePath: string; /** * Lower-cased hosts the document's `servers` (or Swagger `host`) name, without port or scheme. * Empty when the document declares none — then a host cannot be checked, and a consumer must * say so rather than assume a call to any host is a call to this service. */ serverHosts: string[]; operations: ContractOperation[]; /** Named schemas the document declares, sorted by ref. Capped; see `schemasDeclared`. */ schemas: ContractSchema[]; /** * How many named schemas the document DECLARES, which is `schemas.length` unless the reader's * own cap truncated the list. A consumer counting the dropped ones has to subtract from this, * not from what it was handed — a cap that reports the capped number as the total under-states * every drop beyond the first cap. */ schemasDeclared: number; /** Element classes present in the file but outside the model (`callbacks`, `webhooks`, external `$ref`). */ unassessed: string[]; /** Path keys (method-agnostic, parameter names erased) whose operations are behind a ref the model does not read. */ opaquePaths: string[]; } /** * Whether a file's text may be an OpenAPI or Swagger document: an `openapi` or `swagger` key * anywhere (block, flow, or JSON style). A cheap pre-filter only; {@link readOpenApi} decides. */ export declare function looksLikeOpenApi(text: string): boolean; /** * Parse one document. Returns `undefined` when the text is not an OpenAPI or Swagger document; an * `error` when it declares itself one (a top-level `openapi`/`swagger` key) but cannot be read. */ export declare function readOpenApi(file: string, text: string): ContractDocument | { file: string; error: string; } | undefined; //# sourceMappingURL=openapi.d.ts.map