|  | 
|  | 1 | +// openapi-format.d.ts | 
|  | 2 | + | 
|  | 3 | +declare module 'openapi-format' { | 
|  | 4 | +  import { OpenAPIV3 } from 'openapi-types' | 
|  | 5 | + | 
|  | 6 | +  interface OpenAPISortSet { | 
|  | 7 | +    root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'> | 
|  | 8 | +    get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'> | 
|  | 9 | +    post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'> | 
|  | 10 | +    put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'> | 
|  | 11 | +    patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'> | 
|  | 12 | +    delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'> | 
|  | 13 | +    parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'> | 
|  | 14 | +    requestBody?: Array<'description' | 'required' | 'content'> | 
|  | 15 | +    responses?: Array<'description' | 'headers' | 'content' | 'links'> | 
|  | 16 | +    content?: Array<string> | 
|  | 17 | +    components?: Array<'parameters' | 'schemas'> | 
|  | 18 | +    schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'> | 
|  | 19 | +    schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'> | 
|  | 20 | +    properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'> | 
|  | 21 | +    sortPathsBy?: 'original' | 'path' | 'tags' | 
|  | 22 | +  } | 
|  | 23 | + | 
|  | 24 | +  interface OpenAPISortOptions { | 
|  | 25 | +    sortSet: OpenAPISortSet | 
|  | 26 | +    sortComponentsSet?: string[] | 
|  | 27 | +  } | 
|  | 28 | + | 
|  | 29 | +  interface OpenAPIFilterSet { | 
|  | 30 | +    methods?: string[] | 
|  | 31 | +    tags?: string[] | 
|  | 32 | +    operationIds?: string[] | 
|  | 33 | +    operations?: string[] | 
|  | 34 | +    flags?: string[] | 
|  | 35 | +    flagValues?: string[] | 
|  | 36 | +    inverseMethods?: string[] | 
|  | 37 | +    inverseTags?: string[] | 
|  | 38 | +    inverseOperationIds?: string[] | 
|  | 39 | +    responseContent?: string[] | 
|  | 40 | +    inverseResponseContent?: string[] | 
|  | 41 | +    unusedComponents?: string[] | 
|  | 42 | +    stripFlags?: string[] | 
|  | 43 | +    preserveEmptyObjects?: boolean | string[]; | 
|  | 44 | +  } | 
|  | 45 | + | 
|  | 46 | +  interface OpenAPICasingOptions { | 
|  | 47 | +    casingSet?: OpenAPICasingSet | 
|  | 48 | +  } | 
|  | 49 | + | 
|  | 50 | +  interface OpenAPICasingSet { | 
|  | 51 | +    operationId?: string | 
|  | 52 | +    properties?: string | 
|  | 53 | +    parametersQuery?: string | 
|  | 54 | +    parametersHeader?: string | 
|  | 55 | +    parametersPath?: string | 
|  | 56 | +    componentsExamples?: string | 
|  | 57 | +    componentsSchemas?: string | 
|  | 58 | +    componentsHeaders?: string | 
|  | 59 | +    componentsResponses?: string | 
|  | 60 | +    componentsRequestBodies?: string | 
|  | 61 | +    componentsSecuritySchemes?: string | 
|  | 62 | +    componentsParametersQuery?: string | 
|  | 63 | +    componentsParametersHeader?: string | 
|  | 64 | +    componentsParametersPath?: string | 
|  | 65 | +  } | 
|  | 66 | + | 
|  | 67 | +  interface OpenAPIGenerateOptions { | 
|  | 68 | +    generateSet?: OpenAPIGenerateSet | 
|  | 69 | +  } | 
|  | 70 | + | 
|  | 71 | +  interface OpenAPIGenerateSet { | 
|  | 72 | +    operationIdTemplate?: string | 
|  | 73 | +    overwriteExisting?: boolean | 
|  | 74 | +  } | 
|  | 75 | + | 
|  | 76 | +  interface OpenAPIFilterOptions { | 
|  | 77 | +    filterSet?: OpenAPIFilterSet | 
|  | 78 | +    defaultFilter?: OpenAPIFilterSet | 
|  | 79 | +  } | 
|  | 80 | + | 
|  | 81 | +  interface OpenAPIResult { | 
|  | 82 | +    data: OpenAPIV3.Document | string | 
|  | 83 | +    resultData: Record<string, never> | 
|  | 84 | +  } | 
|  | 85 | + | 
|  | 86 | +  export interface AnalyzeOpenApiResult { | 
|  | 87 | +    operations?: string[]; | 
|  | 88 | +    methods?: string[]; | 
|  | 89 | +    paths?: string[]; | 
|  | 90 | +    flags?: string[]; | 
|  | 91 | +    operationIds?: string[]; | 
|  | 92 | +    flagValues?: string[]; | 
|  | 93 | +    responseContent?: string[]; | 
|  | 94 | +    tags?: string[]; | 
|  | 95 | +    [key: string]: string[] | undefined; | 
|  | 96 | +  } | 
|  | 97 | + | 
|  | 98 | +  export interface WriteFileOptions { | 
|  | 99 | +    format?: string; | 
|  | 100 | +    keepComments?: boolean; | 
|  | 101 | +    yamlComments?: Record<string, unknown>; | 
|  | 102 | +    lineWidth?: string | number; | 
|  | 103 | +    mode?: string; | 
|  | 104 | +  } | 
|  | 105 | + | 
|  | 106 | +  /** | 
|  | 107 | +   * Sorts the properties of an OpenAPI document according to the specified sort configuration. | 
|  | 108 | +   * @param {OpenAPIV3.Document} oaObj - The OpenAPI document to be sorted. | 
|  | 109 | +   * @param {OpenAPISortOptions} options - The sorting options. | 
|  | 110 | +   * @returns {Promise<OpenAPIResult>} The sorted OpenAPI document. | 
|  | 111 | +   */ | 
|  | 112 | +  export function openapiSort( | 
|  | 113 | +    oaObj: OpenAPIV3.Document, | 
|  | 114 | +    options: OpenAPISortOptions | 
|  | 115 | +  ): Promise<OpenAPIResult> | 
|  | 116 | + | 
|  | 117 | +  /** | 
|  | 118 | +   * Filters the properties of an OpenAPI document based on the specified filter configuration. | 
|  | 119 | +   * @param {OpenAPIV3.Document} oaObj - The OpenAPI document to be filtered. | 
|  | 120 | +   * @param {OpenAPIFilterOptions} options - The filtering options. | 
|  | 121 | +   * @returns {Promise<OpenAPIResult>} The filtered OpenAPI document. | 
|  | 122 | +   */ | 
|  | 123 | +  export function openapiFilter( | 
|  | 124 | +    oaObj: OpenAPIV3.Document, | 
|  | 125 | +    options: OpenAPIFilterOptions | 
|  | 126 | +  ): Promise<OpenAPIResult> | 
|  | 127 | + | 
|  | 128 | +  /** | 
|  | 129 | +   * Generate elements for an OpenAPI document based on the specified generate configuration. | 
|  | 130 | +   * @param {OpenAPIV3.Document} oaObj - The OpenAPI document. | 
|  | 131 | +   * @param {OpenAPIGenerateOptions} options - The generate options. | 
|  | 132 | +   * @returns {Promise<OpenAPIResult>} The enriched OpenAPI document. | 
|  | 133 | +   */ | 
|  | 134 | +  export function openapiGenerate( | 
|  | 135 | +    oaObj: OpenAPIV3.Document, | 
|  | 136 | +    options: OpenAPIGenerateOptions | 
|  | 137 | +  ): Promise<OpenAPIResult> | 
|  | 138 | + | 
|  | 139 | +  /** | 
|  | 140 | +   * Change the case of properties an OpenAPI document based on the specified casing configuration. | 
|  | 141 | +   * @param {OpenAPIV3.Document} oaObj - The OpenAPI document. | 
|  | 142 | +   * @param {OpenAPICasingOptions} options - The casing options. | 
|  | 143 | +   * @returns {Promise<OpenAPIResult>} The cased OpenAPI document. | 
|  | 144 | +   */ | 
|  | 145 | +  export function openapiChangeCase( | 
|  | 146 | +    oaObj: OpenAPIV3.Document, | 
|  | 147 | +    options: OpenAPICasingOptions | 
|  | 148 | +  ): Promise<OpenAPIResult> | 
|  | 149 | + | 
|  | 150 | +  /** | 
|  | 151 | +   * Parses a JSON or YAML file into a JavaScript object. | 
|  | 152 | +   * @param {string} filePath - The path to the JSON or YAML file. | 
|  | 153 | +   * @param {Record<string, unknown>} [options] - Additional parsing options. | 
|  | 154 | +   * @returns {Promise<Record<string, any>>} The parsed data object. | 
|  | 155 | +   */ | 
|  | 156 | +  export function parseFile( | 
|  | 157 | +    filePath: string, | 
|  | 158 | +    options?: Record<string, unknown> | 
|  | 159 | +  ): Promise<Record<string, any>> | 
|  | 160 | + | 
|  | 161 | +  /** | 
|  | 162 | +   * Parses a JSON or YAML string into a JavaScript object. | 
|  | 163 | +   * @param {string} input - The JSON or YAML string. | 
|  | 164 | +   * @param {Record<string, unknown>} [options] - Additional parsing options. | 
|  | 165 | +   * @returns {Promise<Record<string, any>>} The parsed data object. | 
|  | 166 | +   */ | 
|  | 167 | +  export function parseString( | 
|  | 168 | +    input: string, | 
|  | 169 | +    options?: Record<string, unknown> | 
|  | 170 | +  ): Promise<Record<string, any>> | 
|  | 171 | + | 
|  | 172 | +  /** | 
|  | 173 | +   * Detects the format of a given string as either JSON or YAML. | 
|  | 174 | +   * @param {string} input - The string to detect the format of. | 
|  | 175 | +   * @returns {Promise<'json' | 'yaml' | 'unknown'>} The detected format. | 
|  | 176 | +   */ | 
|  | 177 | +  export function detectFormat( | 
|  | 178 | +    input: string, | 
|  | 179 | +  ): Promise<'json' | 'yaml' | 'unknown'> | 
|  | 180 | + | 
|  | 181 | +  /** | 
|  | 182 | +   * Writes a JavaScript object to a file in JSON or YAML format. | 
|  | 183 | +   * @param {string} filePath - The path to the output file. | 
|  | 184 | +   * @param {Record<string, unknown> | OpenAPIV3.Document} data - The data object to write. | 
|  | 185 | +   * @param {WriteFileOptions} [options] - Additional write options. | 
|  | 186 | +   * @returns {Promise<void>} Resolves when the file has been written. | 
|  | 187 | +   */ | 
|  | 188 | +  export function writeFile( | 
|  | 189 | +    filePath: string, | 
|  | 190 | +    data: Record<string, unknown>, | 
|  | 191 | +    options?: WriteFileOptions | 
|  | 192 | +  ): Promise<void>; | 
|  | 193 | +  /** | 
|  | 194 | +   * Changes the case of a given string to the specified case type. | 
|  | 195 | +   * @param {string} valueAsString - The input string to change the case of. | 
|  | 196 | +   * @param {string} caseType - The target case type (e.g., 'camelCase', 'pascalCase', 'kebabCase', 'snakeCase'). | 
|  | 197 | +   * @returns {string} The string with the specified case. | 
|  | 198 | +   */ | 
|  | 199 | +  export function changeCase(valueAsString: string, caseType: string): string | 
|  | 200 | + | 
|  | 201 | +  /** | 
|  | 202 | +   * Analyze the OpenAPI document. | 
|  | 203 | +   * @param {OpenAPIV3.Document} oaObj - The OpenAPI document as a JSON object. | 
|  | 204 | +   * @returns {AnalyzeOpenApiResult} | 
|  | 205 | +   */ | 
|  | 206 | +  export function analyzeOpenApi(oaObj: Record<string, unknown> | OpenAPIV3.Document): AnalyzeOpenApiResult | 
|  | 207 | + | 
|  | 208 | +  /** | 
|  | 209 | +   * Converts any document to a string representation (e.g., JSON or YAML). | 
|  | 210 | +   * @param {T} document - The document to convert. | 
|  | 211 | +   * @param {Record<string, unknown>} [options] - Additional stringification options. | 
|  | 212 | +   * @returns {Promise<string>} The string representation of the document. | 
|  | 213 | +   */ | 
|  | 214 | +  export function stringify<T extends Record<string, unknown>>( | 
|  | 215 | +    document: T, | 
|  | 216 | +    options?: Record<string, unknown> | 
|  | 217 | +  ): Promise<string>; | 
|  | 218 | +} | 
0 commit comments