@hono-di/swagger 0.0.7 → 0.0.9

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.
package/dist/index.cjs CHANGED
@@ -3,8 +3,14 @@
3
3
  var core = require('@hono-di/core');
4
4
  require('reflect-metadata');
5
5
 
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+
6
9
  // src/document-builder.ts
7
10
  var DocumentBuilder = class {
11
+ static {
12
+ __name(this, "DocumentBuilder");
13
+ }
8
14
  document = {
9
15
  openapi: "3.0.0",
10
16
  info: {
@@ -33,15 +39,25 @@ var DocumentBuilder = class {
33
39
  return this;
34
40
  }
35
41
  setContact(name, url, email) {
36
- this.document.info.contact = { name, url, email };
42
+ this.document.info.contact = {
43
+ name,
44
+ url,
45
+ email
46
+ };
37
47
  return this;
38
48
  }
39
49
  addServer(url, description) {
40
- this.document.servers.push({ url, description });
50
+ this.document.servers.push({
51
+ url,
52
+ description
53
+ });
41
54
  return this;
42
55
  }
43
56
  addTag(name, description) {
44
- this.document.tags.push({ name, description });
57
+ this.document.tags.push({
58
+ name,
59
+ description
60
+ });
45
61
  return this;
46
62
  }
47
63
  addBearerAuth(options = {}, name = "bearer") {
@@ -71,12 +87,14 @@ function ApiTags(...tags) {
71
87
  Reflect.defineMetadata(DECORATORS.API_TAGS, tags, target);
72
88
  };
73
89
  }
90
+ __name(ApiTags, "ApiTags");
74
91
  function ApiOperation(options) {
75
92
  return (target, propertyKey, descriptor) => {
76
93
  Reflect.defineMetadata(DECORATORS.API_OPERATION, options, descriptor.value);
77
94
  return descriptor;
78
95
  };
79
96
  }
97
+ __name(ApiOperation, "ApiOperation");
80
98
  function ApiResponse(options) {
81
99
  return (target, propertyKey, descriptor) => {
82
100
  const responses = Reflect.getMetadata(DECORATORS.API_RESPONSE, descriptor.value) || {};
@@ -85,16 +103,25 @@ function ApiResponse(options) {
85
103
  return descriptor;
86
104
  };
87
105
  }
106
+ __name(ApiResponse, "ApiResponse");
88
107
  function ApiProperty(options = {}) {
89
108
  return (target, propertyKey) => {
90
109
  const properties = Reflect.getMetadata(DECORATORS.API_PROPERTY, target.constructor) || [];
91
- properties.push({ key: propertyKey, ...options });
110
+ properties.push({
111
+ key: propertyKey,
112
+ ...options
113
+ });
92
114
  Reflect.defineMetadata(DECORATORS.API_PROPERTY, properties, target.constructor);
93
115
  };
94
116
  }
117
+ __name(ApiProperty, "ApiProperty");
95
118
 
96
119
  // src/explorers/api-scanner.ts
97
120
  var SwaggerScanner = class {
121
+ static {
122
+ __name(this, "SwaggerScanner");
123
+ }
124
+ container;
98
125
  constructor(container) {
99
126
  this.container = container;
100
127
  }
@@ -109,12 +136,16 @@ var SwaggerScanner = class {
109
136
  }
110
137
  scanController(controller, document) {
111
138
  if (!controller) return;
112
- const { prefix } = Reflect.getMetadata(core.METADATA_KEYS.CONTROLLER, controller) || { prefix: "" };
139
+ const { prefix } = Reflect.getMetadata(core.METADATA_KEYS.CONTROLLER, controller) || {
140
+ prefix: ""
141
+ };
113
142
  const routes = Reflect.getMetadata(core.METADATA_KEYS.ROUTES, controller) || [];
114
143
  const apiTags = Reflect.getMetadata(DECORATORS.API_TAGS, controller) || [];
115
144
  apiTags.forEach((tag) => {
116
145
  if (!document.tags.find((t) => t.name === tag)) {
117
- document.tags.push({ name: tag });
146
+ document.tags.push({
147
+ name: tag
148
+ });
118
149
  }
119
150
  });
120
151
  routes.forEach((route) => {
@@ -140,14 +171,15 @@ var SwaggerScanner = class {
140
171
  };
141
172
  });
142
173
  if (Object.keys(responses).length === 0) {
143
- responses["200"] = { description: "Successful operation" };
174
+ responses["200"] = {
175
+ description: "Successful operation"
176
+ };
144
177
  }
145
178
  return {
146
179
  summary: apiOperation.summary || "",
147
180
  description: apiOperation.description || "",
148
181
  tags: controllerTags,
149
182
  responses
150
- // TODO: Add parameters and request body scanning
151
183
  };
152
184
  }
153
185
  normalizePath(prefix, path) {
@@ -162,6 +194,9 @@ var SwaggerScanner = class {
162
194
 
163
195
  // src/swagger-module.ts
164
196
  var SwaggerModule = class {
197
+ static {
198
+ __name(this, "SwaggerModule");
199
+ }
165
200
  static createDocument(app, config) {
166
201
  const container = app.getContainer();
167
202
  const scanner = new SwaggerScanner(container);
package/dist/index.js CHANGED
@@ -1,8 +1,14 @@
1
1
  import { METADATA_KEYS } from '@hono-di/core';
2
2
  import 'reflect-metadata';
3
3
 
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+
4
7
  // src/document-builder.ts
5
8
  var DocumentBuilder = class {
9
+ static {
10
+ __name(this, "DocumentBuilder");
11
+ }
6
12
  document = {
7
13
  openapi: "3.0.0",
8
14
  info: {
@@ -31,15 +37,25 @@ var DocumentBuilder = class {
31
37
  return this;
32
38
  }
33
39
  setContact(name, url, email) {
34
- this.document.info.contact = { name, url, email };
40
+ this.document.info.contact = {
41
+ name,
42
+ url,
43
+ email
44
+ };
35
45
  return this;
36
46
  }
37
47
  addServer(url, description) {
38
- this.document.servers.push({ url, description });
48
+ this.document.servers.push({
49
+ url,
50
+ description
51
+ });
39
52
  return this;
40
53
  }
41
54
  addTag(name, description) {
42
- this.document.tags.push({ name, description });
55
+ this.document.tags.push({
56
+ name,
57
+ description
58
+ });
43
59
  return this;
44
60
  }
45
61
  addBearerAuth(options = {}, name = "bearer") {
@@ -69,12 +85,14 @@ function ApiTags(...tags) {
69
85
  Reflect.defineMetadata(DECORATORS.API_TAGS, tags, target);
70
86
  };
71
87
  }
88
+ __name(ApiTags, "ApiTags");
72
89
  function ApiOperation(options) {
73
90
  return (target, propertyKey, descriptor) => {
74
91
  Reflect.defineMetadata(DECORATORS.API_OPERATION, options, descriptor.value);
75
92
  return descriptor;
76
93
  };
77
94
  }
95
+ __name(ApiOperation, "ApiOperation");
78
96
  function ApiResponse(options) {
79
97
  return (target, propertyKey, descriptor) => {
80
98
  const responses = Reflect.getMetadata(DECORATORS.API_RESPONSE, descriptor.value) || {};
@@ -83,16 +101,25 @@ function ApiResponse(options) {
83
101
  return descriptor;
84
102
  };
85
103
  }
104
+ __name(ApiResponse, "ApiResponse");
86
105
  function ApiProperty(options = {}) {
87
106
  return (target, propertyKey) => {
88
107
  const properties = Reflect.getMetadata(DECORATORS.API_PROPERTY, target.constructor) || [];
89
- properties.push({ key: propertyKey, ...options });
108
+ properties.push({
109
+ key: propertyKey,
110
+ ...options
111
+ });
90
112
  Reflect.defineMetadata(DECORATORS.API_PROPERTY, properties, target.constructor);
91
113
  };
92
114
  }
115
+ __name(ApiProperty, "ApiProperty");
93
116
 
94
117
  // src/explorers/api-scanner.ts
95
118
  var SwaggerScanner = class {
119
+ static {
120
+ __name(this, "SwaggerScanner");
121
+ }
122
+ container;
96
123
  constructor(container) {
97
124
  this.container = container;
98
125
  }
@@ -107,12 +134,16 @@ var SwaggerScanner = class {
107
134
  }
108
135
  scanController(controller, document) {
109
136
  if (!controller) return;
110
- const { prefix } = Reflect.getMetadata(METADATA_KEYS.CONTROLLER, controller) || { prefix: "" };
137
+ const { prefix } = Reflect.getMetadata(METADATA_KEYS.CONTROLLER, controller) || {
138
+ prefix: ""
139
+ };
111
140
  const routes = Reflect.getMetadata(METADATA_KEYS.ROUTES, controller) || [];
112
141
  const apiTags = Reflect.getMetadata(DECORATORS.API_TAGS, controller) || [];
113
142
  apiTags.forEach((tag) => {
114
143
  if (!document.tags.find((t) => t.name === tag)) {
115
- document.tags.push({ name: tag });
144
+ document.tags.push({
145
+ name: tag
146
+ });
116
147
  }
117
148
  });
118
149
  routes.forEach((route) => {
@@ -138,14 +169,15 @@ var SwaggerScanner = class {
138
169
  };
139
170
  });
140
171
  if (Object.keys(responses).length === 0) {
141
- responses["200"] = { description: "Successful operation" };
172
+ responses["200"] = {
173
+ description: "Successful operation"
174
+ };
142
175
  }
143
176
  return {
144
177
  summary: apiOperation.summary || "",
145
178
  description: apiOperation.description || "",
146
179
  tags: controllerTags,
147
180
  responses
148
- // TODO: Add parameters and request body scanning
149
181
  };
150
182
  }
151
183
  normalizePath(prefix, path) {
@@ -160,6 +192,9 @@ var SwaggerScanner = class {
160
192
 
161
193
  // src/swagger-module.ts
162
194
  var SwaggerModule = class {
195
+ static {
196
+ __name(this, "SwaggerModule");
197
+ }
163
198
  static createDocument(app, config) {
164
199
  const container = app.getContainer();
165
200
  const scanner = new SwaggerScanner(container);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono-di/swagger",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "OpenAPI (Swagger) module for Hono-DI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -21,7 +21,7 @@
21
21
  "test": "bun test"
22
22
  },
23
23
  "dependencies": {
24
- "@hono-di/core": "0.0.7",
24
+ "@hono-di/core": "0.0.9",
25
25
  "reflect-metadata": "^0.2.2"
26
26
  },
27
27
  "peerDependencies": {
@@ -30,6 +30,7 @@
30
30
  "devDependencies": {
31
31
  "tsup": "^8.5.1",
32
32
  "typescript": "^5.4.0",
33
+ "@swc/core": "^1.15.8",
33
34
  "@types/node": "^22.10.6"
34
35
  }
35
36
  }