Skip to content

Commit 2766182

Browse files
danielsharveytheoomoregbee
authored andcommitted
feat(meta.swagger): Add support for swagger.exclude
Improve support for excluding attributes based upon respective `swagger.exclude` attributes (for blueprint select/omit examples).
1 parent b6120a4 commit 2766182

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/generators.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,15 @@ export const generatePaths = (routes: SwaggerRouteInfo[], templates: BlueprintAc
341341

342342
addSelectQueryParam: () => {
343343
if (isParam('query', 'select')) return;
344+
const attributes = route.model!.attributes || {};
345+
const csv = reduce(attributes, (acc, a, n) => ((a.meta?.swagger?.exclude === true) ? acc : [...acc, n]), [] as string[]);
344346
pathEntry.parameters.push({
345347
in: 'query',
346348
name: 'select',
347349
required: false,
348350
schema: {
349351
type: 'string',
350-
example: [...keys(route.model!.attributes || {})].join(','),
352+
example: csv.join(','),
351353
},
352354
description: 'The attributes to include in the result, specified as a comma-delimited list.'
353355
+ ' By default, all attributes are selected.'
@@ -358,13 +360,15 @@ export const generatePaths = (routes: SwaggerRouteInfo[], templates: BlueprintAc
358360

359361
addOmitQueryParam: () => {
360362
if (isParam('query', 'omit')) return;
363+
const attributes = route.model!.attributes || {};
364+
const csv = reduce(attributes, (acc, a, n) => ((a.meta?.swagger?.exclude === true) ? acc : [...acc, n]), [] as string[]);
361365
pathEntry.parameters.push({
362366
in: 'query',
363367
name: 'omit',
364368
required: false,
365369
schema: {
366370
type: 'string',
367-
example: [...keys(route.model!.attributes || {})].join(','),
371+
example: csv.join(','),
368372
},
369373
description: 'The attributes to exclude from the result, specified as a comma-delimited list.'
370374
+ ' Cannot be used in conjuction with `select`.'

0 commit comments

Comments
 (0)