Skip to content

Commit

Permalink
feat: add support for vendor extension renderers (#2545)
Browse files Browse the repository at this point in the history
* feat: add support for vendor extension renderers

* fix: update the code based on PR feedback

* style: resolve linting issues

* fix: add the ability to render vendor extensions in the body

Changed the handling of vendor extensions to allow to render vendor extensions
in the body of a `Model` or `HttpOperation` between the title and the request
block

* clean up usage

---------

Co-authored-by: Daniel A. White <daniel.white@stoplight.io>
  • Loading branch information
weyert and daniel-white committed Jun 3, 2024
1 parent 553dbdc commit f86303c
Show file tree
Hide file tree
Showing 35 changed files with 1,207 additions and 372 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"extends": [
"@commitlint/config-conventional"
]
}
},
"dependencies": {}
}
8 changes: 4 additions & 4 deletions packages/elements-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
},
"dependencies": {
"@stoplight/http-spec": "^7.0.3",
"@stoplight/json": "^3.18.1",
"@stoplight/json-schema-ref-parser": "^9.0.5",
"@stoplight/json-schema-sampler": "0.2.3",
"@stoplight/json": "^3.21.0",
"@stoplight/json-schema-ref-parser": "^9.2.7",
"@stoplight/json-schema-sampler": "0.3.0",
"@stoplight/json-schema-tree": "^4.0.0",
"@stoplight/json-schema-viewer": "4.16.1",
"@stoplight/markdown-viewer": "^5.7.0",
Expand All @@ -70,7 +70,7 @@
"@stoplight/path": "^1.3.2",
"@stoplight/react-error-boundary": "^3.0.0",
"@stoplight/types": "^14.1.1",
"@stoplight/yaml": "^4.2.3",
"@stoplight/yaml": "^4.3.0",
"classnames": "^2.2.6",
"httpsnippet-lite": "^3.0.5",
"jotai": "1.3.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ be the json schema object to be rendered.
"type": "number",
"minimum": 0,
"maximum": 150
},
"type": {
"type": "string",
"enum": ["STANDARD", "ADMIN"],
"x-enum-descriptions": {
"STANDARD": "A standard user",
"ADMIN": "A user with administrative powers"
}
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ This is bundled schema with refs
"property3": {
"type": "boolean",
"description": "Property 3"
},
"property4": {
"type": "string",
"enum": [
"BUSINESS",
"PERSONAL",
"OTHER"
],
"x-enum-descriptions": {
"BUSINESS": "Enum description for BUSINESS",
"PERSONAL": "Enum description for PERSONAL",
"OTHER": "Enum description for OTHER"
}
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions packages/elements-core/src/__fixtures__/operations/put-todos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const httpOperation: IHttpOperation = {
method: 'put',
path: '/todos/{todoId}',
summary: 'Update Todo',
extensions: {
'x-stoplight-info': {
id: 'http-operation-id',
version: '1.0.0',
},
},
responses: [
{
id: '?http-response-200?',
Expand Down Expand Up @@ -79,10 +85,29 @@ export const httpOperation: IHttpOperation = {
minimum: 0,
maximum: 150,
},
plan: {
enum: ['FREE', 'BASIC', 'DELUXE'],
// @ts-ignore
'x-enum-descriptions': {
FREE: 'A happy customer',
BASIC: 'Just what is needed',
DELUXE: 'Big bucks',
},
},
},
required: ['name', 'age'],
description: 'Here lies the user model',
},
type: {
description: 'The type of todo',
type: 'string',
enum: ['REMINDER', 'TASK'],
// @ts-ignore
'x-enum-descriptions': {
REMINDER: 'A reminder',
TASK: 'A task',
},
},
},
required: ['id', 'user'],
},
Expand Down

0 comments on commit f86303c

Please sign in to comment.