vona-module-a-openapi 5.0.14 → 5.0.16

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.js CHANGED
@@ -118,7 +118,7 @@ let ServiceOpenapi = (_dec$1 = Service(), _dec2$1 = BeanInfo({
118
118
  const registry = this._collectRegistry();
119
119
  const generator = version === 'V30' ? new OpenApiGeneratorV3(registry.definitions) : new OpenApiGeneratorV31(registry.definitions);
120
120
  const apiObj = generator.generateDocument(this.scope.config.generateDocument[version]);
121
- this._translate(apiObj);
121
+ this._translate(apiObj, 'api');
122
122
  return apiObj;
123
123
  }
124
124
  generateJsonOfControllerAction(controller, actionKey, version = 'V31') {
@@ -128,10 +128,10 @@ let ServiceOpenapi = (_dec$1 = Service(), _dec2$1 = BeanInfo({
128
128
  this._collectController(registry, beanOptions.module, controller, actionKey);
129
129
  const generator = version === 'V30' ? new OpenApiGeneratorV3(registry.definitions) : new OpenApiGeneratorV31(registry.definitions);
130
130
  const apiObj = generator.generateDocument(this.scope.config.generateDocument[version]);
131
- this._translate(apiObj);
131
+ this._translate(apiObj, 'rest');
132
132
  return apiObj;
133
133
  }
134
- _translate(apiObj) {
134
+ _translate(apiObj, generateJsonScene) {
135
135
  // paths
136
136
  if (apiObj.paths) {
137
137
  for (const key in apiObj.paths) {
@@ -141,10 +141,10 @@ let ServiceOpenapi = (_dec$1 = Service(), _dec2$1 = BeanInfo({
141
141
  this._translateStrings(methodObj, ['description', 'summary']);
142
142
  // parameters
143
143
  for (const parameterObj of methodObj.parameters || []) {
144
- this._translateSchema(parameterObj.schema);
144
+ this._translateSchema(parameterObj.schema, generateJsonScene);
145
145
  }
146
146
  // requestBody
147
- this._translateSchema(methodObj.requestBody?.content?.['application/json']?.schema);
147
+ this._translateSchema(methodObj.requestBody?.content?.['application/json']?.schema, generateJsonScene);
148
148
  }
149
149
  }
150
150
  }
@@ -152,19 +152,23 @@ let ServiceOpenapi = (_dec$1 = Service(), _dec2$1 = BeanInfo({
152
152
  if (apiObj.components?.schemas) {
153
153
  for (const key in apiObj.components.schemas) {
154
154
  const schema = apiObj.components.schemas[key];
155
- this._translateSchema(schema);
155
+ this._translateSchema(schema, generateJsonScene);
156
156
  }
157
157
  }
158
158
  }
159
- _translateSchema(schema) {
159
+ _translateSchema(schema, generateJsonScene) {
160
160
  if (!schema) return;
161
161
  if (schema.type === 'object' && schema.required === undefined) schema.required = [];
162
162
  this._translateStrings(schema, ['title', 'description']);
163
+ if (generateJsonScene === 'api' && !schema.description && schema.title) {
164
+ schema.description = schema.title;
165
+ delete schema.title;
166
+ }
163
167
  const properties = cast(schema).properties;
164
168
  if (properties && typeof properties === 'object') {
165
169
  for (const prop in properties) {
166
170
  const propObj = properties[prop];
167
- this._translateSchema(propObj);
171
+ this._translateSchema(propObj, generateJsonScene);
168
172
  }
169
173
  }
170
174
  }
@@ -20,6 +20,7 @@ export interface IOpenApiOptions {
20
20
  operationId?: string;
21
21
  headers?: IOpenApiHeader[];
22
22
  }
23
+ export type TypeGenerateJsonScene = 'api' | 'rest';
23
24
  export type TypeOpenApiVersion = 'V30' | 'V31';
24
25
  export interface IOpenAPIObject {
25
26
  V30: OpenAPIObject30;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-openapi",
3
3
  "type": "module",
4
- "version": "5.0.14",
4
+ "version": "5.0.16",
5
5
  "title": "a-openapi",
6
6
  "vonaModule": {
7
7
  "capabilities": {
@@ -38,7 +38,7 @@
38
38
  "@cabloy/zod-query": "^1.0.14",
39
39
  "@zhennann/currency": "^2.0.0",
40
40
  "openapi3-ts": "^4.4.0",
41
- "zod": "^3.23.8"
41
+ "zod": "^3.25.58"
42
42
  },
43
43
  "devDependencies": {
44
44
  "clean-package": "^2.2.0",