-
-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add openapi validation for search #5541
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
import { FromSchema } from 'json-schema-to-ts'; | ||
import { variantSchema } from './variant-schema'; | ||
import { constraintSchema } from './constraint-schema'; | ||
import { overrideSchema } from './override-schema'; | ||
import { parametersSchema } from './parameters-schema'; | ||
import { featureStrategySchema } from './feature-strategy-schema'; | ||
import { tagSchema } from './tag-schema'; | ||
import { featureEnvironmentSchema } from './feature-environment-schema'; | ||
import { strategyVariantSchema } from './strategy-variant-schema'; | ||
|
||
export const featureSearchResponseSchema = { | ||
$id: '#/components/schemas/featureSearchResponseSchema', | ||
type: 'object', | ||
additionalProperties: false, | ||
required: ['name'], | ||
description: 'A feature toggle definition', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
example: 'disable-comments', | ||
description: 'Unique feature name', | ||
}, | ||
type: { | ||
type: 'string', | ||
example: 'kill-switch', | ||
description: | ||
'Type of the toggle e.g. experiment, kill-switch, release, operational, permission', | ||
}, | ||
description: { | ||
type: 'string', | ||
nullable: true, | ||
example: | ||
'Controls disabling of the comments section in case of an incident', | ||
description: 'Detailed description of the feature', | ||
}, | ||
archived: { | ||
type: 'boolean', | ||
example: true, | ||
description: '`true` if the feature is archived', | ||
}, | ||
project: { | ||
type: 'string', | ||
example: 'dx-squad', | ||
description: 'Name of the project the feature belongs to', | ||
}, | ||
enabled: { | ||
type: 'boolean', | ||
example: true, | ||
description: '`true` if the feature is enabled, otherwise `false`.', | ||
}, | ||
stale: { | ||
type: 'boolean', | ||
example: false, | ||
description: | ||
'`true` if the feature is stale based on the age and feature type, otherwise `false`.', | ||
}, | ||
favorite: { | ||
type: 'boolean', | ||
example: true, | ||
description: | ||
'`true` if the feature was favorited, otherwise `false`.', | ||
}, | ||
impressionData: { | ||
type: 'boolean', | ||
example: false, | ||
description: | ||
'`true` if the impression data collection is enabled for the feature, otherwise `false`.', | ||
}, | ||
createdAt: { | ||
type: 'string', | ||
format: 'date-time', | ||
nullable: true, | ||
example: '2023-01-28T15:21:39.975Z', | ||
description: 'The date the feature was created', | ||
}, | ||
archivedAt: { | ||
type: 'string', | ||
format: 'date-time', | ||
nullable: true, | ||
example: '2023-01-29T15:21:39.975Z', | ||
description: 'The date the feature was archived', | ||
}, | ||
lastSeenAt: { | ||
type: 'string', | ||
format: 'date-time', | ||
nullable: true, | ||
deprecated: true, | ||
example: '2023-01-28T16:21:39.975Z', | ||
description: | ||
'The date when metrics where last collected for the feature. This field is deprecated, use the one in featureEnvironmentSchema', | ||
}, | ||
environments: { | ||
type: 'array', | ||
items: { | ||
$ref: '#/components/schemas/featureEnvironmentSchema', | ||
}, | ||
description: | ||
'The list of environments where the feature can be used', | ||
}, | ||
segments: { | ||
type: 'array', | ||
description: 'The list of segments the feature is enabled for.', | ||
example: ['pro-users', 'main-segment'], | ||
items: { | ||
type: 'string', | ||
}, | ||
}, | ||
variants: { | ||
type: 'array', | ||
items: { | ||
$ref: '#/components/schemas/variantSchema', | ||
}, | ||
description: 'The list of feature variants', | ||
deprecated: true, | ||
}, | ||
strategies: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
}, | ||
description: 'This is a legacy field that will be deprecated', | ||
deprecated: true, | ||
}, | ||
tags: { | ||
type: 'array', | ||
items: { | ||
$ref: '#/components/schemas/tagSchema', | ||
}, | ||
nullable: true, | ||
description: 'The list of feature tags', | ||
}, | ||
children: { | ||
type: 'array', | ||
description: | ||
'The list of child feature names. This is an experimental field and may change.', | ||
items: { | ||
type: 'string', | ||
example: 'some-feature', | ||
}, | ||
}, | ||
dependencies: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
additionalProperties: false, | ||
required: ['feature'], | ||
properties: { | ||
feature: { | ||
description: 'The name of the parent feature', | ||
type: 'string', | ||
example: 'some-feature', | ||
}, | ||
enabled: { | ||
description: | ||
'Whether the parent feature is enabled or not', | ||
type: 'boolean', | ||
example: true, | ||
}, | ||
variants: { | ||
description: | ||
'The list of variants the parent feature should resolve to. Only valid when feature is enabled.', | ||
type: 'array', | ||
items: { | ||
example: 'some-feature-blue-variant', | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
description: | ||
'The list of parent dependencies. This is an experimental field and may change.', | ||
}, | ||
}, | ||
components: { | ||
schemas: { | ||
constraintSchema, | ||
featureEnvironmentSchema, | ||
featureStrategySchema, | ||
strategyVariantSchema, | ||
overrideSchema, | ||
parametersSchema, | ||
variantSchema, | ||
tagSchema, | ||
}, | ||
}, | ||
} as const; | ||
|
||
export type FeatureSearchResponseSchema = FromSchema< | ||
typeof featureSearchResponseSchema | ||
>; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it renamed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happened because of renaming. Fixed