go-duck-cli 1.4.17 → 1.4.18
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/generators/swagger.js +23 -1
- package/package.json +1 -1
package/generators/swagger.js
CHANGED
|
@@ -121,11 +121,25 @@ export const generateSwaggerDocs = async (config, entities, outputDir, openEntit
|
|
|
121
121
|
|
|
122
122
|
regPath(`${basePath}/${name}s`, 'get', {
|
|
123
123
|
summary: `Get all ${capitalized}s`,
|
|
124
|
+
description: `Retrieves a paginated list of ${capitalized}s. Supports JPA-style dynamic scalar filtering and relationship eager-loading.`,
|
|
124
125
|
parameters: [
|
|
125
126
|
...commonHeaders,
|
|
126
127
|
{ name: 'page', in: 'query', schema: { type: 'integer' }, description: 'Zero-based page index' },
|
|
127
128
|
{ name: 'size', in: 'query', schema: { type: 'integer' }, description: 'Records per page' },
|
|
128
|
-
{ name: '
|
|
129
|
+
{ name: 'sort', in: 'query', schema: { type: 'string' }, description: 'Sort criteria (e.g., name,desc)' },
|
|
130
|
+
{ name: 'eager', in: 'query', schema: { type: 'boolean' }, description: 'If true, performs SQL Join to fetch relations' },
|
|
131
|
+
...entity.fields.map(f => ({
|
|
132
|
+
name: f.name,
|
|
133
|
+
in: 'query',
|
|
134
|
+
schema: getSwaggerFieldSchema(f.type),
|
|
135
|
+
description: `Filter exactly by ${f.name}`
|
|
136
|
+
})),
|
|
137
|
+
...entity.relationships.filter(r => r.to.entity === capitalized).map(r => ({
|
|
138
|
+
name: r.to.field + 'Id',
|
|
139
|
+
in: 'query',
|
|
140
|
+
schema: { type: 'integer' },
|
|
141
|
+
description: `Filter by foreign key ${r.to.field}Id`
|
|
142
|
+
}))
|
|
129
143
|
],
|
|
130
144
|
responses: { 200: { description: 'OK', content: { 'application/json': { schema: { type: 'array', items: { $ref: `#/components/schemas/${capitalized}` } } } } } }
|
|
131
145
|
}, 'read');
|
|
@@ -143,12 +157,20 @@ export const generateSwaggerDocs = async (config, entities, outputDir, openEntit
|
|
|
143
157
|
regPath(`${basePath}/${name}s/{id}`, 'put', {
|
|
144
158
|
summary: `Update ${capitalized}`,
|
|
145
159
|
parameters: [...commonHeaders, { name: 'id', in: 'path', required: true, schema: { type: 'integer' } }],
|
|
160
|
+
requestBody: {
|
|
161
|
+
required: true,
|
|
162
|
+
content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } }
|
|
163
|
+
},
|
|
146
164
|
responses: { 200: { description: 'Updated', content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } } } }
|
|
147
165
|
}, 'update');
|
|
148
166
|
|
|
149
167
|
regPath(`${basePath}/${name}s/{id}`, 'patch', {
|
|
150
168
|
summary: `Patch ${capitalized}`,
|
|
151
169
|
parameters: [...commonHeaders, { name: 'id', in: 'path', required: true, schema: { type: 'integer' } }],
|
|
170
|
+
requestBody: {
|
|
171
|
+
required: true,
|
|
172
|
+
content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } }
|
|
173
|
+
},
|
|
152
174
|
responses: { 200: { description: 'Patched' } }
|
|
153
175
|
}, 'update');
|
|
154
176
|
|