import { BehavioralSummary } from '@suss/behavioral-ir'; type HttpMethod = "get" | "post" | "put" | "delete" | "patch" | "head" | "options" | "trace"; interface OpenApiSpec { openapi?: string; swagger?: string; info?: { title?: string; version?: string; }; /** Swagger 2.0 puts the prefix for every path here. */ basePath?: string; /** OpenAPI 3 puts the prefix in the first server's URL instead. */ servers?: Array<{ url?: string; }>; /** * OpenAPI allows a ref only on each path item, and some split documents * write the whole map as one ref to an index file, which is read too. */ paths?: Record | Reference; /** Swagger 2.0 keeps its named schemas here, where 3.x uses `components.schemas`. */ definitions?: Record; /** Swagger 2.0's shared parameters and responses, where 3.x uses `components`. */ parameters?: Record; responses?: Record; components?: { schemas?: Record; parameters?: Record; requestBodies?: Record; responses?: Record; }; } /** * A pointer to an object written elsewhere, in the same document or in * another file. A path item, a parameter, a request body, a response and * a schema can each be written as one. */ interface Reference { $ref: string; } type PathItem = { parameters?: Array; } & Partial>; interface OpenApiOperation { operationId?: string; summary?: string; description?: string; tags?: string[]; parameters?: Array; requestBody?: OpenApiRequestBody | Reference; responses?: Record; } interface OpenApiParameter { name: string; /** * Swagger 2.0 also writes a request body and a form field as parameters, * `body` and `formData`. OpenAPI 3 moved both into `requestBody`. */ in: "path" | "query" | "header" | "cookie" | "body" | "formData"; required?: boolean; schema?: OpenApiSchema; /** * Swagger 2.0 puts a scalar parameter's type and other schema keywords * on the parameter itself, where 3.x wraps them in `schema`. */ type?: OpenApiSchema["type"]; format?: OpenApiSchema["format"]; items?: OpenApiSchema["items"]; enum?: OpenApiSchema["enum"]; description?: string; } interface OpenApiRequestBody { required?: boolean; content?: Record; description?: string; } interface OpenApiResponse { description?: string; content?: Record; /** Swagger 2.0 writes the body's schema here, with no media type around it. */ schema?: OpenApiSchema; headers?: Record; } interface OpenApiMediaType { schema?: OpenApiSchema; } type SchemaTypeName = "object" | "array" | "string" | "integer" | "number" | "boolean" | "null"; interface OpenApiDiscriminator { propertyName: string; /** * Discriminator value to `$ref`. The `oneOf` or `anyOf` variant with a * matching `$ref` has its `propertyName` narrowed to that value. */ mapping?: Record; } /** * Covers both OpenAPI 3.0 and 3.1. 3.0 marks a nullable schema with * `nullable: true`, and 3.1 follows JSON Schema 2020-12 and lists `"null"` * in `type` instead. `schemaToShape` gives the same TypeShape for both. */ interface OpenApiSchema { $ref?: string; /** 3.1 allows an array of type names, and `"null"` in it means nullable. */ type?: SchemaTypeName | SchemaTypeName[]; /** 3.0 only. */ nullable?: boolean; /** 3.1 shorthand for a one-value enum. */ const?: string | number | boolean | null; enum?: Array; properties?: Record; required?: string[]; additionalProperties?: boolean | OpenApiSchema; items?: OpenApiSchema; oneOf?: OpenApiSchema[]; anyOf?: OpenApiSchema[]; allOf?: OpenApiSchema[]; discriminator?: OpenApiDiscriminator; format?: string; description?: string; example?: unknown; } interface OpenApiToSummariesOptions { /** The source label recorded on each summary, in place of the default. */ source?: string; } interface OpenApiFileToSummariesOptions extends OpenApiToSummariesOptions { /** * Collects each file a `$ref` points to that could not be read, and each * ref that points at nothing. Without it, each goes to stderr. */ warnings?: string[]; } /** * Converts an OpenAPI document already in memory. Each operation becomes * one summary with one transition per declared response status. A `$ref` * inside the document is resolved, and a recursive one stops at a `ref`. * A ref to another file is left unresolved, because a document in memory * has no directory to look in; read it with `openApiFileToSummaries`. */ declare function openApiToSummaries(spec: OpenApiSpec, options?: OpenApiToSummariesOptions): BehavioralSummary[]; /** * Reads an OpenAPI document from a YAML or JSON file and converts it, * along with every file its `$ref`s reach, each resolved relative to the * file the ref is in. A `.json` file is parsed as JSON, and any other file * goes through the YAML parser, which also accepts JSON. Throws when the * file is missing or does not contain an object. */ declare function openApiFileToSummaries(specPath: string, options?: OpenApiFileToSummariesOptions): BehavioralSummary[]; export { type OpenApiFileToSummariesOptions, type OpenApiSpec, type OpenApiToSummariesOptions, type Reference, openApiFileToSummaries, openApiToSummaries };