-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finalize all filters for find dataset endpoints
- Loading branch information
1 parent
05eab47
commit 589bf1e
Showing
5 changed files
with
123 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,66 @@ | ||
import { ContentObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface"; | ||
import { boolean } from "mathjs"; | ||
|
||
const limits = { | ||
limits: { | ||
type: "object", | ||
properties: { | ||
limit: { | ||
type: "number", | ||
}, | ||
skip: { | ||
type: "number", | ||
}, | ||
order: { | ||
type: "array", | ||
items: { | ||
type: "object", | ||
properties: { | ||
field: { | ||
type: "string", | ||
}, | ||
direction: { | ||
type: "string", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
/** | ||
* NOTE: This is disabled only for the official sdk package generation as the schema validation complains about the content field. | ||
* But we want to have it when we run the application as it improves swagger documentation and usage a lot. | ||
* We use "content" property as it is described in the swagger specification: https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content:~:text=explode%3A%20false-,content,-is%20used%20in | ||
*/ | ||
export const swaggerDatasetFilterContent: ContentObject | undefined = boolean( | ||
process.env.SDK_PACKAGE_SWAGGER_HELPERS_DISABLED ?? false, | ||
) | ||
? undefined | ||
: { | ||
"application/json": { | ||
schema: { | ||
type: "object", | ||
properties: { | ||
where: { | ||
type: "object", | ||
}, | ||
include: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
}, | ||
}, | ||
fields: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
export const getSwaggerDatasetFilterContent = ( | ||
includeLimits = true, | ||
): ContentObject | undefined => | ||
boolean(process.env.SDK_PACKAGE_SWAGGER_HELPERS_DISABLED ?? false) | ||
? undefined | ||
: { | ||
"application/json": { | ||
schema: { | ||
type: "object", | ||
properties: { | ||
where: { | ||
type: "object", | ||
}, | ||
}, | ||
limits: { | ||
type: "object", | ||
properties: { | ||
limit: { | ||
type: "number", | ||
}, | ||
skip: { | ||
type: "number", | ||
include: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
}, | ||
order: { | ||
type: "array", | ||
items: { | ||
type: "object", | ||
properties: { | ||
field: { | ||
type: "string", | ||
}, | ||
direction: { | ||
type: "string", | ||
}, | ||
}, | ||
}, | ||
}, | ||
fields: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
}, | ||
}, | ||
...(includeLimits ? limits : {}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; |