Skip to content
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

fix: Ref added under anyOf/oneOf/allOf remove the model description -STOP-95 #2747

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/react-cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"typescript": "^4.3.5"
},
"resolutions": {
"@babel/core": "^7.16.0"
"@babel/core": "^7.16.0",
"@types/react": "17.0.11"
},
"browserslist": {
"production": [
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-core",
"version": "8.5.2",
"version": "8.5.3",
"sideEffects": [
"web-components.min.js",
"src/web-components/**",
Expand Down
61 changes: 50 additions & 11 deletions packages/elements-core/src/components/Docs/Model/Model.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,52 @@ const exampleSchema: JSONSchema7 = {
},
};

const exampleStringSchema: JSONSchema7 = {
type: 'string',
description: 'example schema description that should only show once :)',
const model_data: JSONSchema7 = {
title: 'operator_reference',
description: 'description from allOf Operator',
allOf: [
{
$ref: '#/%24defs/bird',
},
{
$ref: '#/%24defs/animal',
},
],

$defs: {
bird: {
type: 'object',
title: 'bird',
description: 'this is bird model',
properties: {
id: {
type: 'string',
},
bird_type: {
type: 'string',
},
},
},
animal: {
$ref: '#/%24defs/bird',
title: 'animal',
description: 'This is from Animal model',
},
},
};
const props = {
nodeTitle: 'operator_reference',
layoutOptions: {
hideExport: false,
},
exportProps: {
original: {
href: 'https://stoplight-local.com:8443/api/v1/projects/venkat/stop-95/nodes/models/operator_reference.yaml?fromExportButton=true&snapshotType=model',
},
bundled: {
href: 'https://api.stoplight-local.com:8443/projects/cHJqOjE2NA/branches/main/export/models/operator_reference.yaml',
},
},
};

describe('Model', () => {
Expand Down Expand Up @@ -135,13 +178,6 @@ describe('Model', () => {
expect(textboxDescription).toHaveTextContent('example schema description');
});

it('does not display description at top of doc for non-objects', async () => {
render(<Model data={exampleStringSchema} />);
const description = screen.queryByRole('textbox');

expect(description).not.toBeInTheDocument();
});

describe('export button', () => {
it('should render correctly', () => {
const wrapper = render(
Expand All @@ -150,7 +186,6 @@ describe('Model', () => {
data={exampleSchema}
exportProps={{ original: { onPress: jest.fn() }, bundled: { onPress: jest.fn() } }}
/>
,
</MosaicProvider>,
);

Expand Down Expand Up @@ -237,5 +272,9 @@ describe('Model', () => {

unmount();
});
it('CombineSchema must have description', () => {
const { container } = render(<Model data={model_data} {...props} />);
expect(container).toHaveTextContent(`description from allOf Operator`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const ModelComponent: React.FC<ModelProps> = ({
const descriptionChanged = nodeHasChanged?.({ nodeId, attr: 'description' });
const description = (
<VStack spacing={10}>
{data.description && data.type === 'object' && (
{data.description && (
<Box pos="relative">
<MarkdownViewer role="textbox" markdown={data.description} />
<NodeAnnotation change={descriptionChanged} />
Expand Down
4 changes: 2 additions & 2 deletions packages/elements-dev-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-dev-portal",
"version": "2.5.2",
"version": "2.5.3",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@stoplight/markdown-viewer": "^5.7.1",
"@stoplight/mosaic": "^1.53.4",
"@stoplight/elements-core": "^8.5.2",
"@stoplight/elements-core": "^8.5.3",
"@stoplight/path": "^1.3.2",
"@stoplight/types": "^14.0.0",
"classnames": "^2.2.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements",
"version": "8.5.2",
"version": "8.5.3",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -63,7 +63,7 @@
]
},
"dependencies": {
"@stoplight/elements-core": "^8.5.2",
"@stoplight/elements-core": "^8.5.3",
"@stoplight/http-spec": "^7.1.0",
"@stoplight/json": "^3.18.1",
"@stoplight/mosaic": "^1.53.4",
Expand Down