@@ -10,17 +10,17 @@ import { transformAll } from "./transform/index.js";
1010import { makeApiPathsEnum } from "./transform/paths.js" ;
1111export * from "./types.js" ; // expose all types to consumers
1212
13- export const WARNING_MESSAGE = `/**
14- * This file was auto-generated by openapi-typescript.
15- * Do not make direct changes to the file.
16- */
13+ export const COMMENT_HEADER = `/**
14+ * This file was auto-generated by openapi-typescript.
15+ * Do not make direct changes to the file.
16+ */
1717
1818
1919` ;
2020
2121/**
2222 * This function is the entry to the program and allows the user to pass in a remote schema and/or local schema.
23- * The URL or schema and headers can be passed in either programtically and/or via the CLI.
23+ * The URL or schema and headers can be passed in either programmatically and/or via the CLI.
2424 * Remote schemas are fetched from a server that supplies JSON or YAML format via an HTTP GET request. File based schemas
2525 * are loaded in via file path, most commonly prefixed with the file:// format. Alternatively, the user can pass in
2626 * OpenAPI2 or OpenAPI3 schema objects that can be parsed directly by the function without reading the file system.
@@ -38,14 +38,15 @@ async function openapiTS(
3838 const ctx : GlobalContext = {
3939 additionalProperties : options . additionalProperties || false ,
4040 auth : options . auth ,
41+ commentHeader : typeof options . commentHeader === "string" ? options . commentHeader : COMMENT_HEADER ,
4142 defaultNonNullable : options . defaultNonNullable || false ,
4243 formatter : options && typeof options . formatter === "function" ? options . formatter : undefined ,
4344 immutableTypes : options . immutableTypes || false ,
44- rawSchema : options . rawSchema || false ,
4545 makePathsEnum : options . makePathsEnum || false ,
46- version : options . version || 3 ,
47- supportArrayLength : options . supportArrayLength ,
4846 pathParamsAsTypes : options . pathParamsAsTypes ,
47+ rawSchema : options . rawSchema || false ,
48+ supportArrayLength : options . supportArrayLength ,
49+ version : options . version || 3 ,
4950 } ;
5051
5152 // note: we may be loading many large schemas into memory at once; take care to reuse references without cloning
@@ -76,7 +77,7 @@ async function openapiTS(
7677 }
7778
7879 // 2. generate raw output
79- let output = WARNING_MESSAGE ;
80+ let output = ctx . commentHeader ;
8081
8182 // 2a. root schema
8283 if ( ! options ?. version && ! ctx . rawSchema ) ctx . version = swaggerVersion ( rootSchema as any ) ; // note: root version cascades down to all subschemas
0 commit comments