typed-openapi 0.1.4 → 0.2.0

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.
@@ -373,6 +373,7 @@ var generateEndpointSchemaList = (ctx) => {
373
373
  ${parameters.query ? `query: ${parameterObjectToString(parameters.query)},` : ""}
374
374
  ${parameters.path ? `path: ${parameterObjectToString(parameters.path)},` : ""}
375
375
  ${parameters.header ? `header: ${parameterObjectToString(parameters.header)},` : ""}
376
+ ${parameters.body ? `body: ${parameterObjectToString(parameters.body)},` : ""}
376
377
  }` : "parameters: never,"}
377
378
  response: ${ctx.runtime === "none" ? endpoint.response.recompute((box) => {
378
379
  if (Box.isReference(box) && !box.params.generics) {
@@ -727,16 +728,21 @@ var mapOpenApiEndpoints = (doc) => {
727
728
  (acc, paramOrRef) => {
728
729
  const param = refs.unwrap(paramOrRef);
729
730
  const schema = openApiSchemaToTs({ schema: refs.unwrap(param.schema ?? {}), ctx });
730
- lists.query.push(param);
731
731
  if (param.required)
732
732
  endpoint.meta.areParametersRequired = true;
733
733
  endpoint.meta.hasParameters = true;
734
- if (param.in === "query")
734
+ if (param.in === "query") {
735
+ lists.query.push(param);
735
736
  acc.query[param.name] = schema;
736
- if (param.in === "path")
737
+ }
738
+ if (param.in === "path") {
739
+ lists.path.push(param);
737
740
  acc.path[param.name] = schema;
738
- if (param.in === "header")
741
+ }
742
+ if (param.in === "header") {
743
+ lists.header.push(param);
739
744
  acc.header[param.name] = schema;
745
+ }
740
746
  return acc;
741
747
  },
742
748
  { query: {}, path: {}, header: {} }
@@ -748,6 +754,7 @@ var mapOpenApiEndpoints = (doc) => {
748
754
  return acc;
749
755
  }, {});
750
756
  if (operation.requestBody) {
757
+ endpoint.meta.hasParameters = true;
751
758
  const requestBody = refs.unwrap(operation.requestBody ?? {});
752
759
  const content2 = requestBody.content;
753
760
  const matchingMediaType = Object.keys(content2).find(isAllowedParamMediaTypes);
package/dist/cli.cjs CHANGED
@@ -31,7 +31,7 @@ var import_promises = require("fs/promises");
31
31
 
32
32
  // package.json
33
33
  var name = "typed-openapi";
34
- var version = "0.1.4";
34
+ var version = "0.2.0";
35
35
 
36
36
  // src/generator.ts
37
37
  var import_server2 = require("pastable/server");
@@ -408,6 +408,7 @@ var generateEndpointSchemaList = (ctx) => {
408
408
  ${parameters.query ? `query: ${parameterObjectToString(parameters.query)},` : ""}
409
409
  ${parameters.path ? `path: ${parameterObjectToString(parameters.path)},` : ""}
410
410
  ${parameters.header ? `header: ${parameterObjectToString(parameters.header)},` : ""}
411
+ ${parameters.body ? `body: ${parameterObjectToString(parameters.body)},` : ""}
411
412
  }` : "parameters: never,"}
412
413
  response: ${ctx.runtime === "none" ? endpoint.response.recompute((box) => {
413
414
  if (Box.isReference(box) && !box.params.generics) {
@@ -764,16 +765,21 @@ var mapOpenApiEndpoints = (doc) => {
764
765
  (acc, paramOrRef) => {
765
766
  const param = refs.unwrap(paramOrRef);
766
767
  const schema = openApiSchemaToTs({ schema: refs.unwrap(param.schema ?? {}), ctx });
767
- lists.query.push(param);
768
768
  if (param.required)
769
769
  endpoint.meta.areParametersRequired = true;
770
770
  endpoint.meta.hasParameters = true;
771
- if (param.in === "query")
771
+ if (param.in === "query") {
772
+ lists.query.push(param);
772
773
  acc.query[param.name] = schema;
773
- if (param.in === "path")
774
+ }
775
+ if (param.in === "path") {
776
+ lists.path.push(param);
774
777
  acc.path[param.name] = schema;
775
- if (param.in === "header")
778
+ }
779
+ if (param.in === "header") {
780
+ lists.header.push(param);
776
781
  acc.header[param.name] = schema;
782
+ }
777
783
  return acc;
778
784
  },
779
785
  { query: {}, path: {}, header: {} }
@@ -785,6 +791,7 @@ var mapOpenApiEndpoints = (doc) => {
785
791
  return acc;
786
792
  }, {});
787
793
  if (operation.requestBody) {
794
+ endpoint.meta.hasParameters = true;
788
795
  const requestBody = refs.unwrap(operation.requestBody ?? {});
789
796
  const content2 = requestBody.content;
790
797
  const matchingMediaType = Object.keys(content2).find(isAllowedParamMediaTypes);
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  allowedRuntimes,
3
3
  generateFile,
4
4
  mapOpenApiEndpoints
5
- } from "./chunk-TUNDL3P7.js";
5
+ } from "./chunk-A3A4AVLF.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import SwaggerParser from "@apidevtools/swagger-parser";
@@ -13,7 +13,7 @@ import { writeFile } from "fs/promises";
13
13
 
14
14
  // package.json
15
15
  var name = "typed-openapi";
16
- var version = "0.1.4";
16
+ var version = "0.2.0";
17
17
 
18
18
  // src/cli.ts
19
19
  var cwd = process.cwd();
package/dist/index.cjs CHANGED
@@ -416,6 +416,7 @@ var generateEndpointSchemaList = (ctx) => {
416
416
  ${parameters.query ? `query: ${parameterObjectToString(parameters.query)},` : ""}
417
417
  ${parameters.path ? `path: ${parameterObjectToString(parameters.path)},` : ""}
418
418
  ${parameters.header ? `header: ${parameterObjectToString(parameters.header)},` : ""}
419
+ ${parameters.body ? `body: ${parameterObjectToString(parameters.body)},` : ""}
419
420
  }` : "parameters: never,"}
420
421
  response: ${ctx.runtime === "none" ? endpoint.response.recompute((box) => {
421
422
  if (Box.isReference(box) && !box.params.generics) {
@@ -772,16 +773,21 @@ var mapOpenApiEndpoints = (doc) => {
772
773
  (acc, paramOrRef) => {
773
774
  const param = refs.unwrap(paramOrRef);
774
775
  const schema = openApiSchemaToTs({ schema: refs.unwrap(param.schema ?? {}), ctx });
775
- lists.query.push(param);
776
776
  if (param.required)
777
777
  endpoint.meta.areParametersRequired = true;
778
778
  endpoint.meta.hasParameters = true;
779
- if (param.in === "query")
779
+ if (param.in === "query") {
780
+ lists.query.push(param);
780
781
  acc.query[param.name] = schema;
781
- if (param.in === "path")
782
+ }
783
+ if (param.in === "path") {
784
+ lists.path.push(param);
782
785
  acc.path[param.name] = schema;
783
- if (param.in === "header")
786
+ }
787
+ if (param.in === "header") {
788
+ lists.header.push(param);
784
789
  acc.header[param.name] = schema;
790
+ }
785
791
  return acc;
786
792
  },
787
793
  { query: {}, path: {}, header: {} }
@@ -793,6 +799,7 @@ var mapOpenApiEndpoints = (doc) => {
793
799
  return acc;
794
800
  }, {});
795
801
  if (operation.requestBody) {
802
+ endpoint.meta.hasParameters = true;
796
803
  const requestBody = refs.unwrap(operation.requestBody ?? {});
797
804
  const content2 = requestBody.content;
798
805
  const matchingMediaType = Object.keys(content2).find(isAllowedParamMediaTypes);
package/dist/index.d.cts CHANGED
@@ -208,7 +208,7 @@ declare const mapOpenApiEndpoints: (doc: OpenAPIObject) => {
208
208
  type MutationMethod = "post" | "put" | "patch" | "delete";
209
209
  type Method = "get" | "head" | "options" | MutationMethod;
210
210
  type EndpointParameters = {
211
- body?: Box;
211
+ body?: Box<BoxRef>;
212
212
  query?: Box<BoxRef> | Record<string, AnyBox>;
213
213
  header?: Box<BoxRef> | Record<string, AnyBox>;
214
214
  path?: Box<BoxRef> | Record<string, AnyBox>;
package/dist/index.d.ts CHANGED
@@ -208,7 +208,7 @@ declare const mapOpenApiEndpoints: (doc: OpenAPIObject) => {
208
208
  type MutationMethod = "post" | "put" | "patch" | "delete";
209
209
  type Method = "get" | "head" | "options" | MutationMethod;
210
210
  type EndpointParameters = {
211
- body?: Box;
211
+ body?: Box<BoxRef>;
212
212
  query?: Box<BoxRef> | Record<string, AnyBox>;
213
213
  header?: Box<BoxRef> | Record<string, AnyBox>;
214
214
  path?: Box<BoxRef> | Record<string, AnyBox>;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  openApiSchemaToTs,
8
8
  tsFactory,
9
9
  unwrap
10
- } from "./chunk-TUNDL3P7.js";
10
+ } from "./chunk-A3A4AVLF.js";
11
11
  export {
12
12
  createBoxFactory,
13
13
  createFactory,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typed-openapi",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.2.0",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
7
7
  "bin": {
package/src/generator.ts CHANGED
@@ -143,6 +143,7 @@ const generateEndpointSchemaList = (ctx: GeneratorContext) => {
143
143
  ${parameters.query ? `query: ${parameterObjectToString(parameters.query)},` : ""}
144
144
  ${parameters.path ? `path: ${parameterObjectToString(parameters.path)},` : ""}
145
145
  ${parameters.header ? `header: ${parameterObjectToString(parameters.header)},` : ""}
146
+ ${parameters.body ? `body: ${parameterObjectToString(parameters.body)},` : ""}
146
147
  }`
147
148
  : "parameters: never,"
148
149
  }
@@ -39,14 +39,22 @@ export const mapOpenApiEndpoints = (doc: OpenAPIObject) => {
39
39
  (acc, paramOrRef) => {
40
40
  const param = refs.unwrap(paramOrRef);
41
41
  const schema = openApiSchemaToTs({ schema: refs.unwrap(param.schema ?? {}), ctx });
42
- lists.query.push(param);
43
42
 
44
43
  if (param.required) endpoint.meta.areParametersRequired = true;
45
44
  endpoint.meta.hasParameters = true;
46
45
 
47
- if (param.in === "query") acc.query[param.name] = schema;
48
- if (param.in === "path") acc.path[param.name] = schema;
49
- if (param.in === "header") acc.header[param.name] = schema;
46
+ if (param.in === "query") {
47
+ lists.query.push(param);
48
+ acc.query[param.name] = schema;
49
+ }
50
+ if (param.in === "path") {
51
+ lists.path.push(param);
52
+ acc.path[param.name] = schema;
53
+ }
54
+ if (param.in === "header") {
55
+ lists.header.push(param);
56
+ acc.header[param.name] = schema;
57
+ }
50
58
 
51
59
  return acc;
52
60
  },
@@ -64,6 +72,7 @@ export const mapOpenApiEndpoints = (doc: OpenAPIObject) => {
64
72
 
65
73
  // Body
66
74
  if (operation.requestBody) {
75
+ endpoint.meta.hasParameters = true;
67
76
  const requestBody = refs.unwrap(operation.requestBody ?? {});
68
77
  const content = requestBody.content;
69
78
  const matchingMediaType = Object.keys(content).find(isAllowedParamMediaTypes);
@@ -146,7 +155,7 @@ type MutationMethod = "post" | "put" | "patch" | "delete";
146
155
  type Method = "get" | "head" | "options" | MutationMethod;
147
156
 
148
157
  export type EndpointParameters = {
149
- body?: Box;
158
+ body?: Box<BoxRef>;
150
159
  query?: Box<BoxRef> | Record<string, AnyBox>;
151
160
  header?: Box<BoxRef> | Record<string, AnyBox>;
152
161
  path?: Box<BoxRef> | Record<string, AnyBox>;