@typespec/openapi3 0.64.0-dev.1 → 0.64.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +4 -0
  2. package/dist/src/attach-extensions.d.ts +3 -0
  3. package/dist/src/attach-extensions.d.ts.map +1 -0
  4. package/dist/src/attach-extensions.js +11 -0
  5. package/dist/src/attach-extensions.js.map +1 -0
  6. package/dist/src/encoding.d.ts +2 -2
  7. package/dist/src/encoding.d.ts.map +1 -1
  8. package/dist/src/encoding.js +3 -2
  9. package/dist/src/encoding.js.map +1 -1
  10. package/dist/src/json-schema.d.ts +3 -0
  11. package/dist/src/json-schema.d.ts.map +1 -0
  12. package/dist/src/json-schema.js +9 -0
  13. package/dist/src/json-schema.js.map +1 -0
  14. package/dist/src/lib.d.ts +1 -0
  15. package/dist/src/lib.d.ts.map +1 -1
  16. package/dist/src/lib.js +12 -0
  17. package/dist/src/lib.js.map +1 -1
  18. package/dist/src/openapi-helpers-3-0.d.ts +6 -0
  19. package/dist/src/openapi-helpers-3-0.d.ts.map +1 -0
  20. package/dist/src/openapi-helpers-3-0.js +15 -0
  21. package/dist/src/openapi-helpers-3-0.js.map +1 -0
  22. package/dist/src/openapi-helpers-3-1.d.ts +6 -0
  23. package/dist/src/openapi-helpers-3-1.d.ts.map +1 -0
  24. package/dist/src/openapi-helpers-3-1.js +23 -0
  25. package/dist/src/openapi-helpers-3-1.js.map +1 -0
  26. package/dist/src/openapi-spec-mappings.d.ts +33 -0
  27. package/dist/src/openapi-spec-mappings.d.ts.map +1 -0
  28. package/dist/src/openapi-spec-mappings.js +53 -0
  29. package/dist/src/openapi-spec-mappings.js.map +1 -0
  30. package/dist/src/openapi.d.ts +2 -1
  31. package/dist/src/openapi.d.ts.map +1 -1
  32. package/dist/src/openapi.js +42 -44
  33. package/dist/src/openapi.js.map +1 -1
  34. package/dist/src/schema-emitter-3-0.d.ts +19 -0
  35. package/dist/src/schema-emitter-3-0.d.ts.map +1 -0
  36. package/dist/src/schema-emitter-3-0.js +199 -0
  37. package/dist/src/schema-emitter-3-0.js.map +1 -0
  38. package/dist/src/schema-emitter-3-1.d.ts +24 -0
  39. package/dist/src/schema-emitter-3-1.d.ts.map +1 -0
  40. package/dist/src/schema-emitter-3-1.js +226 -0
  41. package/dist/src/schema-emitter-3-1.js.map +1 -0
  42. package/dist/src/schema-emitter.d.ts +33 -10
  43. package/dist/src/schema-emitter.d.ts.map +1 -1
  44. package/dist/src/schema-emitter.js +104 -280
  45. package/dist/src/schema-emitter.js.map +1 -1
  46. package/dist/src/std-scalar-schemas.d.ts +2 -2
  47. package/dist/src/std-scalar-schemas.d.ts.map +1 -1
  48. package/dist/src/types.d.ts +352 -2
  49. package/dist/src/types.d.ts.map +1 -1
  50. package/dist/src/util.d.ts +10 -0
  51. package/dist/src/util.d.ts.map +1 -1
  52. package/dist/src/util.js +42 -0
  53. package/dist/src/util.js.map +1 -1
  54. package/dist/src/xml-module.d.ts +3 -3
  55. package/dist/src/xml-module.d.ts.map +1 -1
  56. package/dist/src/xml-module.js.map +1 -1
  57. package/package.json +6 -1
package/README.md CHANGED
@@ -74,6 +74,10 @@ Example Multiple service with versioning
74
74
  - `openapi.Org1.Service2.v1.0.yaml`
75
75
  - `openapi.Org1.Service2.v1.1.yaml`
76
76
 
77
+ ### `openapi-versions`
78
+
79
+ **Type:** `array`
80
+
77
81
  ### `new-line`
78
82
 
79
83
  **Type:** `"crlf" | "lf"`
@@ -0,0 +1,3 @@
1
+ import { Program, Type } from "@typespec/compiler";
2
+ export declare function attachExtensions(program: Program, type: Type, emitObject: any): void;
3
+ //# sourceMappingURL=attach-extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-extensions.d.ts","sourceRoot":"","sources":["../../src/attach-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAGnD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,QAQ7E"}
@@ -0,0 +1,11 @@
1
+ import { getExtensions } from "@typespec/openapi";
2
+ export function attachExtensions(program, type, emitObject) {
3
+ // Attach any OpenAPI extensions
4
+ const extensions = getExtensions(program, type);
5
+ if (extensions) {
6
+ for (const key of extensions.keys()) {
7
+ emitObject[key] = extensions.get(key);
8
+ }
9
+ }
10
+ }
11
+ //# sourceMappingURL=attach-extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-extensions.js","sourceRoot":"","sources":["../../src/attach-extensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,OAAgB,EAAE,IAAU,EAAE,UAAe;IAC5E,gCAAgC;IAChC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type ModelProperty, Program, type Scalar } from "@typespec/compiler";
2
2
  import type { ResolvedOpenAPI3EmitterOptions } from "./openapi.js";
3
- import type { OpenAPI3Schema } from "./types.js";
4
- export declare function applyEncoding(program: Program, typespecType: Scalar | ModelProperty, target: OpenAPI3Schema, options: ResolvedOpenAPI3EmitterOptions): OpenAPI3Schema;
3
+ import type { OpenAPI3Schema, OpenAPISchema3_1 } from "./types.js";
4
+ export declare function applyEncoding(program: Program, typespecType: Scalar | ModelProperty, target: OpenAPI3Schema | OpenAPISchema3_1, getEncodedFieldName: (typespecType: Scalar | ModelProperty) => string, options: ResolvedOpenAPI3EmitterOptions): OpenAPI3Schema & OpenAPISchema3_1;
5
5
  //# sourceMappingURL=encoding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAEzF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAAG,aAAa,EACpC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,8BAA8B,GACtC,cAAc,CAehB"}
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAEzF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAAG,aAAa,EACpC,MAAM,EAAE,cAAc,GAAG,gBAAgB,EACzC,mBAAmB,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,KAAK,MAAM,EACrE,OAAO,EAAE,8BAA8B,GACtC,cAAc,GAAG,gBAAgB,CAgBnC"}
@@ -1,14 +1,15 @@
1
1
  import { getEncode } from "@typespec/compiler";
2
2
  import { ObjectBuilder } from "@typespec/compiler/emitter-framework";
3
3
  import { getSchemaForStdScalars } from "./std-scalar-schemas.js";
4
- export function applyEncoding(program, typespecType, target, options) {
4
+ export function applyEncoding(program, typespecType, target, getEncodedFieldName, options) {
5
5
  const encodeData = getEncode(program, typespecType);
6
6
  if (encodeData) {
7
7
  const newTarget = new ObjectBuilder(target);
8
8
  const newType = getSchemaForStdScalars(encodeData.type, options);
9
9
  newTarget.type = newType.type;
10
10
  // If the target already has a format it takes priority. (e.g. int32)
11
- newTarget.format = mergeFormatAndEncoding(newTarget.format, encodeData.encoding, newType.format);
11
+ const encodedFieldName = getEncodedFieldName(typespecType);
12
+ newTarget[encodedFieldName] = mergeFormatAndEncoding(newTarget[encodedFieldName], encodeData.encoding, newType.format);
12
13
  return newTarget;
13
14
  }
14
15
  return new ObjectBuilder(target);
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,MAAM,UAAU,aAAa,CAC3B,OAAgB,EAChB,YAAoC,EACpC,MAAsB,EACtB,OAAuC;IAEvC,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACpD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,sBAAsB,CAAC,UAAU,CAAC,IAAW,EAAE,OAAO,CAAC,CAAC;QACxE,SAAS,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC9B,qEAAqE;QACrE,SAAS,CAAC,MAAM,GAAG,sBAAsB,CACvC,SAAS,CAAC,MAAM,EAChB,UAAU,CAAC,QAAQ,EACnB,OAAO,CAAC,MAAM,CACf,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AAC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C;QAC9B,qEAAqE;QACrE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAC3D,SAAS,CAAC,gBAAgB,CAAC,GAAG,sBAAsB,CAClD,SAAS,CAAC,gBAAgB,CAAC,EAC3B,UAAU,CAAC,QAAQ,EACnB,OAAO,CAAC,MAAM,CACf,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,sBAAsB,CAC7B,MAA0B,EAC1B,QAA4B,EAC5B,cAAkC;IAElC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,cAAc,IAAI,QAAQ,IAAI,MAAM,CAAC;QAC9C,KAAK,WAAW;YACd,QAAQ,QAAQ,EAAE,CAAC;gBACjB,KAAK,SAAS;oBACZ,OAAO,WAAW,CAAC;gBACrB,KAAK,eAAe;oBAClB,OAAO,UAAU,CAAC;gBACpB,KAAK,SAAS;oBACZ,OAAO,WAAW,CAAC;gBACrB;oBACE,OAAO,QAAQ,CAAC;YACpB,CAAC;QACH,KAAK,UAAU;YACb,QAAQ,QAAQ,EAAE,CAAC;gBACjB,KAAK,SAAS;oBACZ,OAAO,UAAU,CAAC;gBACpB;oBACE,OAAO,cAAc,IAAI,QAAQ,CAAC;YACtC,CAAC;QACH;YACE,OAAO,cAAc,IAAI,QAAQ,IAAI,MAAM,CAAC;IAChD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type JsonSchemaModule = typeof import("@typespec/json-schema");
2
+ export declare function resolveJsonSchemaModule(): Promise<JsonSchemaModule | undefined>;
3
+ //# sourceMappingURL=json-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/json-schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,cAAc,uBAAuB,CAAC,CAAC;AAEtE,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAMrF"}
@@ -0,0 +1,9 @@
1
+ export async function resolveJsonSchemaModule() {
2
+ try {
3
+ return await import("@typespec/json-schema");
4
+ }
5
+ catch {
6
+ return undefined;
7
+ }
8
+ }
9
+ //# sourceMappingURL=json-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../src/json-schema.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
package/dist/src/lib.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { JSONSchemaType } from "@typespec/compiler";
2
2
  export type FileType = "yaml" | "json";
3
+ export type OpenAPIVersion = "3.0.0" | "3.1.0";
3
4
  export interface OpenAPI3EmitterOptions {
4
5
  /**
5
6
  * If the content should be serialized as YAML or JSON.
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,cAAc,EAAgB,MAAM,oBAAoB,CAAC;AAEzF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AACvC,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IAEH,WAAW,CAAC,EAAE,QAAQ,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IAEpD;;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43
+ items: {
44
+ type: "string",
45
+ enum: ["3.0.0", "3.1.0"],
46
+ nullable: true,
47
+ description: "The versions of OpenAPI to emit. Defaults to `[3.0.0]`",
48
+ },
49
+ nullable: true,
50
+ uniqueItems: true,
51
+ minItems: 1,
52
+ },
41
53
  "new-line": {
42
54
  type: "string",
43
55
  enum: ["crlf", "lf"],
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAkB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkEzF,MAAM,oBAAoB,GAA2C;IACnE,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YACtB,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,8HAA8H;SACjI;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE;gBACX,0BAA0B;gBAC1B,qDAAqD;gBACrD,mDAAmD;gBACnD,iDAAiD;gBACjD,EAAE;gBACF,yFAAyF;gBACzF,EAAE;gBACF,uCAAuC;gBACvC,oBAAoB;gBACpB,EAAE;gBACF,0CAA0C;gBAC1C,kCAAkC;gBAClC,kCAAkC;gBAClC,EAAE;gBACF,yCAAyC;gBACzC,uBAAuB;gBACvB,uBAAuB;gBACvB,EAAE;gBACF,2CAA2C;gBAC3C,qCAAqC;gBACrC,qCAAqC;gBACrC,uCAAuC;gBACvC,2CAA2C;aAC5C,CAAC,IAAI,CAAC,IAAI,CAAC;SACb;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;YACpB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,+CAA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QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,IAAI,MAAM,4CAA4C;aAC5E;SACF;QACD,kBAAkB,EAAE;YAClB,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,mBAAmB,UAAU,8EAA8E;aACjI;SACF;QACD,qCAAqC,EAAE;YACrC,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,sFAAsF,MAAM,yCAAyC;aAC3J;SACF;QACD,qCAAqC,EAAE;YACrC,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,8GAA8G,MAAM,oBAAoB;aAC9J;SACF;QACD,mCAAmC,EAAE;YACnC,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,gBAAgB,OAAO,8IAA8I;aAC3L;SACF;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,oBAA8D;KACxE;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OpenApiSpecSpecificProps } from "./openapi-spec-mappings.js";
2
+ import { OpenAPI3Schema } from "./types.js";
3
+ export declare const applyEncoding: OpenApiSpecSpecificProps["applyEncoding"];
4
+ export declare const getRawBinarySchema: () => OpenAPI3Schema;
5
+ export declare const isRawBinarySchema: (schema: OpenAPI3Schema) => boolean;
6
+ //# sourceMappingURL=openapi-helpers-3-0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-helpers-3-0.d.ts","sourceRoot":"","sources":["../../src/openapi-helpers-3-0.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO5C,eAAO,MAAM,aAAa,EAAE,wBAAwB,CAAC,eAAe,CAOnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,cAErC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,cAAc,KAAG,OAE1D,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { applyEncoding as baseApplyEncoding } from "./encoding.js";
2
+ function getEncodingFieldName() {
3
+ // In Open API 3.0, format is always used for encoding.
4
+ return "format";
5
+ }
6
+ export const applyEncoding = (program, typespecType, target, options) => {
7
+ return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options);
8
+ };
9
+ export const getRawBinarySchema = () => {
10
+ return { type: "string", format: "binary" };
11
+ };
12
+ export const isRawBinarySchema = (schema) => {
13
+ return schema.type === "string" && schema.format === "binary";
14
+ };
15
+ //# sourceMappingURL=openapi-helpers-3-0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-helpers-3-0.js","sourceRoot":"","sources":["../../src/openapi-helpers-3-0.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAInE,SAAS,oBAAoB;IAC3B,uDAAuD;IACvD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAA8C,CACtE,OAAO,EACP,YAAY,EACZ,MAAM,EACN,OAAO,EACP,EAAE;IACF,OAAO,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAmB,EAAE;IACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAsB,EAAW,EAAE;IACnE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC;AAChE,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OpenApiSpecSpecificProps } from "./openapi-spec-mappings.js";
2
+ import { OpenAPISchema3_1 } from "./types.js";
3
+ export declare const applyEncoding: OpenApiSpecSpecificProps["applyEncoding"];
4
+ export declare const getRawBinarySchema: (contentType?: string) => OpenAPISchema3_1;
5
+ export declare const isRawBinarySchema: (schema: OpenAPISchema3_1) => boolean;
6
+ //# sourceMappingURL=openapi-helpers-3-1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-helpers-3-1.d.ts","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAc9C,eAAO,MAAM,aAAa,EAAE,wBAAwB,CAAC,eAAe,CAOnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,MAAM,KAAG,gBAKzD,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,gBAAgB,KAAG,OAE5D,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { applyEncoding as baseApplyEncoding } from "./encoding.js";
2
+ import { isScalarExtendsBytes } from "./util.js";
3
+ function getEncodingFieldName(typespecType) {
4
+ // In Open API 3.1, `contentEncoding` is used for encoded binary data instead of `format`.
5
+ const typeIsBytes = isScalarExtendsBytes(typespecType.kind === "ModelProperty" ? typespecType.type : typespecType);
6
+ if (typeIsBytes) {
7
+ return "contentEncoding";
8
+ }
9
+ return "format";
10
+ }
11
+ export const applyEncoding = (program, typespecType, target, options) => {
12
+ return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options);
13
+ };
14
+ export const getRawBinarySchema = (contentType) => {
15
+ if (contentType) {
16
+ return { contentMediaType: contentType };
17
+ }
18
+ return {};
19
+ };
20
+ export const isRawBinarySchema = (schema) => {
21
+ return schema.type === undefined;
22
+ };
23
+ //# sourceMappingURL=openapi-helpers-3-1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-helpers-3-1.js","sourceRoot":"","sources":["../../src/openapi-helpers-3-1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,SAAS,oBAAoB,CAAC,YAAoC;IAChE,0FAA0F;IAC1F,MAAM,WAAW,GAAG,oBAAoB,CACtC,YAAY,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CACzE,CAAC;IACF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAA8C,CACtE,OAAO,EACP,YAAY,EACZ,MAAM,EACN,OAAO,EACP,EAAE;IACF,OAAO,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAAoB,EAAoB,EAAE;IAC3E,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAwB,EAAW,EAAE;IACrE,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { EmitContext, ModelProperty, Namespace, Program, Scalar } from "@typespec/compiler";
2
+ import { AssetEmitter } from "@typespec/compiler/emitter-framework";
3
+ import { MetadataInfo } from "@typespec/http";
4
+ import { JsonSchemaModule } from "./json-schema.js";
5
+ import { OpenAPI3EmitterOptions, OpenAPIVersion } from "./lib.js";
6
+ import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js";
7
+ import { OpenAPI3Schema, OpenAPISchema3_1, SupportedOpenAPIDocuments } from "./types.js";
8
+ import { VisibilityUsageTracker } from "./visibility-usage.js";
9
+ import { XmlModule } from "./xml-module.js";
10
+ export type CreateSchemaEmitter = (props: {
11
+ program: Program;
12
+ context: EmitContext<OpenAPI3EmitterOptions>;
13
+ metadataInfo: MetadataInfo;
14
+ visibilityUsage: VisibilityUsageTracker;
15
+ options: ResolvedOpenAPI3EmitterOptions;
16
+ optionalDependencies: {
17
+ jsonSchemaModule?: JsonSchemaModule;
18
+ xmlModule?: XmlModule;
19
+ };
20
+ }) => AssetEmitter<OpenAPI3Schema | OpenAPISchema3_1, OpenAPI3EmitterOptions>;
21
+ export interface OpenApiSpecSpecificProps {
22
+ applyEncoding(program: Program, typespecType: Scalar | ModelProperty, target: OpenAPI3Schema, options: ResolvedOpenAPI3EmitterOptions): OpenAPI3Schema & OpenAPISchema3_1;
23
+ createRootDoc: (program: Program, serviceType: Namespace, serviceVersion?: string) => SupportedOpenAPIDocuments;
24
+ createSchemaEmitter: CreateSchemaEmitter;
25
+ /**
26
+ * Returns the binary description for an unencoded binary type
27
+ * @see https://spec.openapis.org/oas/v3.1.1.html#migrating-binary-descriptions-from-oas-3-0
28
+ */
29
+ getRawBinarySchema(contentType?: string): OpenAPI3Schema | OpenAPISchema3_1;
30
+ isRawBinarySchema(schema: OpenAPI3Schema | OpenAPISchema3_1): boolean;
31
+ }
32
+ export declare function getOpenApiSpecProps(specVersion: OpenAPIVersion): OpenApiSpecSpecificProps;
33
+ //# sourceMappingURL=openapi-spec-mappings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AE,CACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,EACtB,cAAc,CAAC,EAAE,MAAM,KACpB,yBAAyB,CAAC;IAE/B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC;;;OAGG;IACH,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,gBAAgB,CAAC;IAE5E,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG,OAAO,CAAC;CACvE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,cAAc,GAAG,wBAAwB,CAuBzF"}
@@ -0,0 +1,53 @@
1
+ import { getExternalDocs, resolveInfo } from "@typespec/openapi";
2
+ import { applyEncoding as applyEncoding3_0, getRawBinarySchema as getRawBinarySchema3_0, isRawBinarySchema as isRawBinarySchema3_0, } from "./openapi-helpers-3-0.js";
3
+ import { applyEncoding as applyEncoding3_1, getRawBinarySchema as getRawBinarySchema3_1, isRawBinarySchema as isRawBinarySchema3_1, } from "./openapi-helpers-3-1.js";
4
+ import { createSchemaEmitter3_0 } from "./schema-emitter-3-0.js";
5
+ import { createSchemaEmitter3_1 } from "./schema-emitter-3-1.js";
6
+ export function getOpenApiSpecProps(specVersion) {
7
+ switch (specVersion) {
8
+ case "3.0.0":
9
+ return {
10
+ applyEncoding: applyEncoding3_0,
11
+ createRootDoc(program, serviceType, serviceVersion) {
12
+ return createRoot(program, serviceType, specVersion, serviceVersion);
13
+ },
14
+ createSchemaEmitter: createSchemaEmitter3_0,
15
+ getRawBinarySchema: getRawBinarySchema3_0,
16
+ isRawBinarySchema: isRawBinarySchema3_0,
17
+ };
18
+ case "3.1.0":
19
+ return {
20
+ applyEncoding: applyEncoding3_1,
21
+ createRootDoc(program, serviceType, serviceVersion) {
22
+ return createRoot(program, serviceType, specVersion, serviceVersion);
23
+ },
24
+ createSchemaEmitter: createSchemaEmitter3_1,
25
+ getRawBinarySchema: getRawBinarySchema3_1,
26
+ isRawBinarySchema: isRawBinarySchema3_1,
27
+ };
28
+ }
29
+ }
30
+ function createRoot(program, serviceType, specVersion, serviceVersion) {
31
+ const info = resolveInfo(program, serviceType);
32
+ return {
33
+ openapi: specVersion,
34
+ info: {
35
+ title: "(title)",
36
+ ...info,
37
+ version: serviceVersion ?? info?.version ?? "0.0.0",
38
+ },
39
+ externalDocs: getExternalDocs(program, serviceType),
40
+ tags: [],
41
+ paths: {},
42
+ security: undefined,
43
+ components: {
44
+ parameters: {},
45
+ requestBodies: {},
46
+ responses: {},
47
+ schemas: {},
48
+ examples: {},
49
+ securitySchemes: {},
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=openapi-spec-mappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-spec-mappings.js","sourceRoot":"","sources":["../../src/openapi-spec-mappings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGjE,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,kBAAkB,IAAI,qBAAqB,EAC3C,iBAAiB,IAAI,oBAAoB,GAC1C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,kBAAkB,IAAI,qBAAqB,EAC3C,iBAAiB,IAAI,oBAAoB,GAC1C,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAqCjE,MAAM,UAAU,mBAAmB,CAAC,WAA2B;IAC7D,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO;gBACL,aAAa,EAAE,gBAAgB;gBAC/B,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,cAAc;oBAChD,OAAO,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;gBACvE,CAAC;gBACD,mBAAmB,EAAE,sBAAsB;gBAC3C,kBAAkB,EAAE,qBAAqB;gBACzC,iBAAiB,EAAE,oBAAoB;aACxC,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,aAAa,EAAE,gBAAgB;gBAC/B,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,cAAc;oBAChD,OAAO,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;gBACvE,CAAC;gBACD,mBAAmB,EAAE,sBAAsB;gBAC3C,kBAAkB,EAAE,qBAAqB;gBACzC,iBAAiB,EAAE,oBAAoB;aACxC,CAAC;IACN,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CACjB,OAAgB,EAChB,WAAsB,EACtB,WAA2B,EAC3B,cAAuB;IAEvB,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAE/C,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,GAAG,IAAI;YACP,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,OAAO,IAAI,OAAO;SACpD;QACD,YAAY,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC;QACnD,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,SAAS;QACnB,UAAU,EAAE;YACV,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE,EAAE;YACZ,eAAe,EAAE,EAAE;SACpB;KACF,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { EmitContext, NewLine, Program } from "@typespec/compiler";
2
- import { FileType, OpenAPI3EmitterOptions } from "./lib.js";
2
+ import { FileType, OpenAPI3EmitterOptions, OpenAPIVersion } from "./lib.js";
3
3
  import { OpenAPI3ServiceRecord } from "./types.js";
4
4
  export declare function $onEmit(context: EmitContext<OpenAPI3EmitterOptions>): Promise<void>;
5
5
  type IrrelevantOpenAPI3EmitterOptionsForObject = "file-type" | "output-file" | "new-line";
@@ -16,6 +16,7 @@ export declare function resolveOptions(context: EmitContext<OpenAPI3EmitterOptio
16
16
  export interface ResolvedOpenAPI3EmitterOptions {
17
17
  fileType: FileType;
18
18
  outputFile: string;
19
+ openapiVersions: OpenAPIVersion[];
19
20
  newLine: NewLine;
20
21
  omitUnreachableTypes: boolean;
21
22
  includeXTypeSpecName: "inline-only" | "never";
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EA+BX,OAAO,EACP,OAAO,EAOR,MAAM,oBAAoB,CAAC;AA+C5B,OAAO,EAAoB,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,EAeL,qBAAqB,EAKtB,MAAM,YAAY,CAAC;AAapB,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,sBAAsB,CAAC,iBAIzE;AAED,KAAK,yCAAyC,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;AAE1F;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,IAAI,CAAC,sBAAsB,EAAE,yCAAyC,CAAM,GACpF,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAgBlC;AAgBD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,sBAAsB,CAAC,GAC3C,8BAA8B,CAgBhC;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oBAAoB,EAAE,aAAa,GAAG,OAAO,CAAC;IAC9C,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC;CACzC"}
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EA+BX,OAAO,EACP,OAAO,EAOR,MAAM,oBAAoB,CAAC;AA8C5B,OAAO,EAAoB,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG9F,OAAO,EAcL,qBAAqB,EAOtB,MAAM,YAAY,CAAC;AAmBpB,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,sBAAsB,CAAC,iBAMzE;AAED,KAAK,yCAAyC,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;AAE1F;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,IAAI,CAAC,sBAAsB,EAAE,yCAAyC,CAAM,GACpF,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAoBlC;AAgBD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,sBAAsB,CAAC,GAC3C,8BAA8B,CAsBhC;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oBAAoB,EAAE,aAAa,GAAG,OAAO,CAAC;IAC9C,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC;CACzC"}
@@ -1,16 +1,16 @@
1
1
  import { compilerAssert, createDiagnosticCollector, emitFile, getAllTags, getAnyExtensionFromPath, getDoc, getFormat, getKnownValues, getMaxItems, getMaxLength, getMaxValue, getMaxValueExclusive, getMinItems, getMinLength, getMinValue, getMinValueExclusive, getNamespaceFullName, getPattern, getService, getSummary, ignoreDiagnostics, interpolatePath, isDeprecated, isGlobalNamespace, isNeverType, isSecret, isVoidType, listServices, navigateTypesInNamespace, projectProgram, resolvePath, } from "@typespec/compiler";
2
2
  import { createAssetEmitter } from "@typespec/compiler/emitter-framework";
3
3
  import { createMetadataInfo, getHttpService, getServers, getStatusCodeDescription, isContentTypeHeader, isOrExtendsHttpFile, isOverloadSameEndpoint, reportIfNoRoutes, resolveAuthentication, resolveRequestVisibility, Visibility, } from "@typespec/http";
4
- import { getExtensions, getExternalDocs, getOpenAPITypeName, getParameterKey, getTagsMetadata, isReadonlyProperty, resolveInfo, resolveOperationId, shouldInline, } from "@typespec/openapi";
4
+ import { getExtensions, getExternalDocs, getOpenAPITypeName, getParameterKey, getTagsMetadata, isReadonlyProperty, resolveOperationId, shouldInline, } from "@typespec/openapi";
5
5
  import { buildVersionProjections } from "@typespec/versioning";
6
6
  import { stringify } from "yaml";
7
7
  import { getRef } from "./decorators.js";
8
- import { applyEncoding } from "./encoding.js";
9
8
  import { getExampleOrExamples, resolveOperationExamples } from "./examples.js";
9
+ import { resolveJsonSchemaModule } from "./json-schema.js";
10
10
  import { createDiagnostic } from "./lib.js";
11
- import { getDefaultValue, isBytesKeptRaw, OpenAPI3SchemaEmitter } from "./schema-emitter.js";
11
+ import { getOpenApiSpecProps } from "./openapi-spec-mappings.js";
12
12
  import { getOpenAPI3StatusCodes } from "./status-codes.js";
13
- import { deepEquals, isSharedHttpOperation } from "./util.js";
13
+ import { deepEquals, getDefaultValue, isBytesKeptRaw, isSharedHttpOperation, } from "./util.js";
14
14
  import { resolveVisibilityUsage } from "./visibility-usage.js";
15
15
  import { resolveXmlModule } from "./xml-module.js";
16
16
  const defaultFileType = "yaml";
@@ -22,8 +22,10 @@ const defaultOptions = {
22
22
  };
23
23
  export async function $onEmit(context) {
24
24
  const options = resolveOptions(context);
25
- const emitter = createOAPIEmitter(context, options);
26
- await emitter.emitOpenAPI();
25
+ for (const specVersion of options.openapiVersions) {
26
+ const emitter = createOAPIEmitter(context, options, specVersion);
27
+ await emitter.emitOpenAPI();
28
+ }
27
29
  }
28
30
  /**
29
31
  * Get the OpenAPI 3 document records from the given program. The documents are
@@ -44,8 +46,12 @@ export async function getOpenAPI3(program, options = {}) {
44
46
  },
45
47
  };
46
48
  const resolvedOptions = resolveOptions(context);
47
- const emitter = createOAPIEmitter(context, resolvedOptions);
48
- return emitter.getOpenAPI();
49
+ const serviceRecords = [];
50
+ for (const specVersion of resolvedOptions.openapiVersions) {
51
+ const emitter = createOAPIEmitter(context, resolvedOptions, specVersion);
52
+ serviceRecords.push(...(await emitter.getOpenAPI()));
53
+ }
54
+ return serviceRecords;
49
55
  }
50
56
  function findFileTypeFromFilename(filename) {
51
57
  if (filename === undefined) {
@@ -65,16 +71,20 @@ export function resolveOptions(context) {
65
71
  const resolvedOptions = { ...defaultOptions, ...context.options };
66
72
  const fileType = resolvedOptions["file-type"] ?? findFileTypeFromFilename(resolvedOptions["output-file"]);
67
73
  const outputFile = resolvedOptions["output-file"] ?? `openapi.{service-name}.{version}.${fileType}`;
74
+ const openapiVersions = resolvedOptions["openapi-versions"] ?? ["3.0.0"];
75
+ const specDir = openapiVersions.length > 1 ? "{openapi-version}" : "";
68
76
  return {
69
77
  fileType,
70
78
  newLine: resolvedOptions["new-line"],
71
79
  omitUnreachableTypes: resolvedOptions["omit-unreachable-types"],
72
80
  includeXTypeSpecName: resolvedOptions["include-x-typespec-name"],
73
81
  safeintStrategy: resolvedOptions["safeint-strategy"],
74
- outputFile: resolvePath(context.emitterOutputDir, outputFile),
82
+ outputFile: resolvePath(context.emitterOutputDir, specDir, outputFile),
83
+ openapiVersions,
75
84
  };
76
85
  }
77
- function createOAPIEmitter(context, options) {
86
+ function createOAPIEmitter(context, options, specVersion = "3.0.0") {
87
+ const { applyEncoding, createRootDoc, createSchemaEmitter, getRawBinarySchema, isRawBinarySchema, } = getOpenApiSpecProps(specVersion);
78
88
  let program = context.program;
79
89
  let schemaEmitter;
80
90
  let root;
@@ -141,7 +151,7 @@ function createOAPIEmitter(context, options) {
141
151
  }
142
152
  }
143
153
  }
144
- function initializeEmitter(service, allHttpAuthentications, defaultAuth, xmlModule, version) {
154
+ function initializeEmitter(service, allHttpAuthentications, defaultAuth, optionalDependencies, version) {
145
155
  diagnostics = createDiagnosticCollector();
146
156
  currentService = service;
147
157
  metadataInfo = createMetadataInfo(program, {
@@ -149,34 +159,21 @@ function createOAPIEmitter(context, options) {
149
159
  canShareProperty: (p) => isReadonlyProperty(program, p),
150
160
  });
151
161
  visibilityUsage = resolveVisibilityUsage(program, metadataInfo, service.type, options.omitUnreachableTypes);
152
- schemaEmitter = createAssetEmitter(program, class extends OpenAPI3SchemaEmitter {
153
- constructor(emitter) {
154
- super(emitter, metadataInfo, visibilityUsage, options, xmlModule);
155
- }
156
- }, context);
162
+ schemaEmitter = createSchemaEmitter({
163
+ program,
164
+ context,
165
+ metadataInfo,
166
+ visibilityUsage,
167
+ options,
168
+ optionalDependencies,
169
+ });
157
170
  const securitySchemes = getOpenAPISecuritySchemes(allHttpAuthentications);
158
171
  const security = getOpenAPISecurity(defaultAuth);
159
- const info = resolveInfo(program, service.type);
160
- root = {
161
- openapi: "3.0.0",
162
- info: {
163
- title: "(title)",
164
- ...info,
165
- version: version ?? info?.version ?? "0.0.0",
166
- },
167
- externalDocs: getExternalDocs(program, service.type),
168
- tags: [],
169
- paths: {},
170
- security: security.length > 0 ? security : undefined,
171
- components: {
172
- parameters: {},
173
- requestBodies: {},
174
- responses: {},
175
- schemas: {},
176
- examples: {},
177
- securitySchemes: securitySchemes,
178
- },
179
- };
172
+ root = createRootDoc(program, service.type, version);
173
+ if (security.length > 0) {
174
+ root.security = security;
175
+ }
176
+ root.components.securitySchemes = securitySchemes;
180
177
  const servers = getServers(program, service.type);
181
178
  if (servers) {
182
179
  root.servers = resolveServers(servers);
@@ -323,6 +320,7 @@ function createOAPIEmitter(context, options) {
323
320
  }
324
321
  function resolveOutputFile(service, multipleService, version) {
325
322
  return interpolatePath(options.outputFile, {
323
+ "openapi-version": specVersion,
326
324
  "service-name": multipleService ? getNamespaceFullName(service.type) : undefined,
327
325
  version,
328
326
  });
@@ -428,7 +426,8 @@ function createOAPIEmitter(context, options) {
428
426
  const httpService = ignoreDiagnostics(getHttpService(program, service.type));
429
427
  const auth = (serviceAuth = resolveAuthentication(httpService));
430
428
  const xmlModule = await resolveXmlModule();
431
- initializeEmitter(service, auth.schemes, auth.defaultAuth, xmlModule, version);
429
+ const jsonSchemaModule = await resolveJsonSchemaModule();
430
+ initializeEmitter(service, auth.schemes, auth.defaultAuth, { xmlModule, jsonSchemaModule }, version);
432
431
  reportIfNoRoutes(program, httpService.operations);
433
432
  for (const op of resolveOperations(httpService.operations)) {
434
433
  const result = getOperationOrSharedOperation(op);
@@ -755,7 +754,7 @@ function createOAPIEmitter(context, options) {
755
754
  function getBodyContentEntry(body, visibility, contentType, examples) {
756
755
  const isBinary = isBinaryPayload(body.type, contentType);
757
756
  if (isBinary) {
758
- return { schema: { type: "string", format: "binary" } };
757
+ return { schema: getRawBinarySchema(contentType) };
759
758
  }
760
759
  const oai3Examples = examples && getExampleOrExamples(program, examples);
761
760
  switch (body.bodyKind) {
@@ -782,7 +781,7 @@ function createOAPIEmitter(context, options) {
782
781
  for (const [partIndex, part] of body.parts.entries()) {
783
782
  const partName = part.name ?? `part${partIndex}`;
784
783
  let schema = isBytesKeptRaw(program, part.body.type)
785
- ? { type: "string", format: "binary" }
784
+ ? getRawBinarySchema()
786
785
  : getSchemaForSingleBody(part.body.type, visibility, part.body.isExplicit && part.body.containsMetadataAnnotations, part.body.type.kind === "Union" ? contentType : undefined);
787
786
  if (part.multi) {
788
787
  schema = {
@@ -850,10 +849,8 @@ function createOAPIEmitter(context, options) {
850
849
  case "text/plain":
851
850
  return schema.type === "string" || schema.type === "number";
852
851
  case "application/octet-stream":
853
- return ((schema.type === "string" && schema.format === "binary") ||
854
- (schema.type === "array" &&
855
- schema.items?.type === "string" &&
856
- schema.items?.format === "binary"));
852
+ return (isRawBinarySchema(schema) ||
853
+ (schema.type === "array" && !!schema.items && isRawBinarySchema(schema.items)));
857
854
  case "application/json":
858
855
  return schema.type === "object";
859
856
  }
@@ -1345,6 +1342,7 @@ function serializeDocument(root, fileType) {
1345
1342
  singleQuote: true,
1346
1343
  aliasDuplicateObjects: false,
1347
1344
  lineWidth: 0,
1345
+ compat: "yaml-1.1",
1348
1346
  });
1349
1347
  }
1350
1348
  }