Skip to content

Commit

Permalink
chore: amend open api tags descriptions and examples (#3519)
Browse files Browse the repository at this point in the history
## About the changes
Adds descriptions and examples to tag schemas
  • Loading branch information
gastonfournier committed Apr 14, 2023
1 parent 74986d6 commit d4c24c9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/lib/openapi/meta-schema-rules.test.ts
Expand Up @@ -92,7 +92,6 @@ const metaRules: Rule[] = [
'featuresSchema',
'featureStrategySchema',
'featureStrategySegmentSchema',
'featureTagSchema',
'featureTypeSchema',
'featureTypesSchema',
'featureUsageSchema',
Expand Down Expand Up @@ -144,9 +143,6 @@ const metaRules: Rule[] = [
'stateSchema',
'strategiesSchema',
'strategySchema',
'tagsBulkAddSchema',
'tagSchema',
'tagsSchema',
'tagTypeSchema',
'tagTypesSchema',
'tagWithVersionSchema',
Expand All @@ -157,7 +153,6 @@ const metaRules: Rule[] = [
'updateFeatureStrategySchema',
'updateTagTypeSchema',
'updateUserSchema',
'updateTagsSchema',
'upsertContextFieldSchema',
'upsertSegmentSchema',
'upsertStrategySchema',
Expand Down
13 changes: 13 additions & 0 deletions src/lib/openapi/spec/feature-tag-schema.ts
Expand Up @@ -3,23 +3,36 @@ import { FromSchema } from 'json-schema-to-ts';
export const featureTagSchema = {
$id: '#/components/schemas/featureTagSchema',
type: 'object',
description: 'Describes a tag applied to a feature',
additionalProperties: false,
required: ['featureName', 'tagValue'],
properties: {
featureName: {
type: 'string',
example: 'my-feature',
description: 'The name of the feature this tag is applied to',
},
tagType: {
type: 'string',
example: 'simple',
description: 'The type of tag',
},
tagValue: {
type: 'string',
example: 'my-tag',
description: 'The value of the tag',
},
type: {
deprecated: true,
type: 'string',
description:
'This field is deprecated and currently unused, use tagType instead',
},
value: {
deprecated: true,
type: 'string',
description:
'This field is deprecated and currently unused, use tagValue instead',
},
},
components: {},
Expand Down
9 changes: 5 additions & 4 deletions src/lib/openapi/spec/tag-schema.ts
Expand Up @@ -5,25 +5,26 @@ export const TAG_MAX_LENGTH = 50;
export const tagSchema = {
$id: '#/components/schemas/tagSchema',
type: 'object',
description: 'Representation of a tag',
additionalProperties: false,
required: ['value', 'type'],
properties: {
value: {
type: 'string',
minLength: TAG_MIN_LENGTH,
maxLength: TAG_MAX_LENGTH,
description: 'The value of the tag',
example: 'a-tag-value',
},
type: {
type: 'string',
minLength: TAG_MIN_LENGTH,
maxLength: TAG_MAX_LENGTH,
default: 'simple',
description: 'The type of the tag',
example: 'simple',
},
},
example: {
value: 'tag-value',
type: 'simple',
},
components: {},
} as const;

Expand Down
4 changes: 4 additions & 0 deletions src/lib/openapi/spec/tags-bulk-add-schema.ts
Expand Up @@ -4,18 +4,22 @@ import { tagSchema } from './tag-schema';

export const tagsBulkAddSchema = {
$id: '#/components/schemas/tagsBulkAddSchema',
description: 'Represents tag changes to be applied to a list of features.',
type: 'object',
additionalProperties: false,
required: ['features', 'tags'],
properties: {
features: {
description:
'The list of features that will be affected by the tag changes.',
type: 'array',
items: {
type: 'string',
minLength: 1,
},
},
tags: {
description: 'The tag changes to be applied to the features.',
$ref: '#/components/schemas/updateTagsSchema',
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/lib/openapi/spec/tags-schema.ts
Expand Up @@ -3,15 +3,18 @@ import { tagSchema } from './tag-schema';

export const tagsSchema = {
$id: '#/components/schemas/tagsSchema',
description: 'A list of tags with a version number',
type: 'object',
additionalProperties: false,
required: ['version', 'tags'],
properties: {
version: {
type: 'integer',
description: 'The version of the schema used to model the tags.',
},
tags: {
type: 'array',
description: 'A list of tags.',
items: {
$ref: '#/components/schemas/tagSchema',
},
Expand Down
3 changes: 3 additions & 0 deletions src/lib/openapi/spec/update-tags-schema.ts
Expand Up @@ -4,17 +4,20 @@ import { tagSchema } from './tag-schema';
export const updateTagsSchema = {
$id: '#/components/schemas/updateTagsSchema',
type: 'object',
description: 'Represents a set of changes to tags of a feature.',
additionalProperties: false,
required: ['addedTags', 'removedTags'],
properties: {
addedTags: {
type: 'array',
description: 'Tags to add to the feature.',
items: {
$ref: '#/components/schemas/tagSchema',
},
},
removedTags: {
type: 'array',
description: 'Tags to remove from the feature.',
items: {
$ref: '#/components/schemas/tagSchema',
},
Expand Down
29 changes: 25 additions & 4 deletions src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap
Expand Up @@ -1618,20 +1618,31 @@ exports[`should serve the OpenAPI spec 1`] = `
},
"featureTagSchema": {
"additionalProperties": false,
"description": "Describes a tag applied to a feature",
"properties": {
"featureName": {
"description": "The name of the feature this tag is applied to",
"example": "my-feature",
"type": "string",
},
"tagType": {
"description": "The type of tag",
"example": "simple",
"type": "string",
},
"tagValue": {
"description": "The value of the tag",
"example": "my-tag",
"type": "string",
},
"type": {
"deprecated": true,
"description": "This field is deprecated and currently unused, use tagType instead",
"type": "string",
},
"value": {
"deprecated": true,
"description": "This field is deprecated and currently unused, use tagValue instead",
"type": "string",
},
},
Expand Down Expand Up @@ -3706,18 +3717,19 @@ Stats are divided into current and previous **windows**.
},
"tagSchema": {
"additionalProperties": false,
"example": {
"type": "simple",
"value": "tag-value",
},
"description": "Representation of a tag",
"properties": {
"type": {
"default": "simple",
"description": "The type of the tag",
"example": "simple",
"maxLength": 50,
"minLength": 2,
"type": "string",
},
"value": {
"description": "The value of the tag",
"example": "a-tag-value",
"maxLength": 50,
"minLength": 2,
"type": "string",
Expand Down Expand Up @@ -3785,8 +3797,10 @@ Stats are divided into current and previous **windows**.
},
"tagsBulkAddSchema": {
"additionalProperties": false,
"description": "Represents tag changes to be applied to a list of features.",
"properties": {
"features": {
"description": "The list of features that will be affected by the tag changes.",
"items": {
"minLength": 1,
"type": "string",
Expand All @@ -3795,6 +3809,7 @@ Stats are divided into current and previous **windows**.
},
"tags": {
"$ref": "#/components/schemas/updateTagsSchema",
"description": "The tag changes to be applied to the features.",
},
},
"required": [
Expand All @@ -3805,14 +3820,17 @@ Stats are divided into current and previous **windows**.
},
"tagsSchema": {
"additionalProperties": false,
"description": "A list of tags with a version number",
"properties": {
"tags": {
"description": "A list of tags.",
"items": {
"$ref": "#/components/schemas/tagSchema",
},
"type": "array",
},
"version": {
"description": "The version of the schema used to model the tags.",
"type": "integer",
},
},
Expand Down Expand Up @@ -4028,6 +4046,7 @@ Stats are divided into current and previous **windows**.
},
"updateTagsSchema": {
"additionalProperties": false,
"description": "Represents a set of changes to tags of a feature.",
"example": {
"addedTags": [
{
Expand All @@ -4044,12 +4063,14 @@ Stats are divided into current and previous **windows**.
},
"properties": {
"addedTags": {
"description": "Tags to add to the feature.",
"items": {
"$ref": "#/components/schemas/tagSchema",
},
"type": "array",
},
"removedTags": {
"description": "Tags to remove from the feature.",
"items": {
"$ref": "#/components/schemas/tagSchema",
},
Expand Down

1 comment on commit d4c24c9

@vercel
Copy link

@vercel vercel bot commented on d4c24c9 Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

unleash-monorepo-frontend – ./frontend

Please sign in to comment.