Skip to content

Commit

Permalink
Merge branch 'main' into vite-react-web-component-support
Browse files Browse the repository at this point in the history
  • Loading branch information
aerialist7 authored May 8, 2022
2 parents da322d2 + b171d27 commit 351474e
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('API component', () => {

it('navigates via table of contents', () => {
loadZoomApiPage();
cy.findByText('groups').click();
cy.findByText('Groups').click();
cy.findByText('Create a group').click();
cy.findByRole('heading', { name: /Create a group/i }).should('exist');
});
Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stoplight/elements": "^7.5.17",
"@stoplight/elements": "^7.5.18",
"@stoplight/mosaic": "^1.15.4",
"history": "^5.0.0",
"react": "16.14.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/elements-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-core",
"version": "7.5.17",
"version": "7.5.18",
"sideEffects": [
"web-components.min.js",
"src/web-components/**",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@stoplight/json-schema-ref-parser": "^9.0.5",
"@stoplight/json-schema-sampler": "0.2.2",
"@stoplight/json-schema-viewer": "^4.5.0",
"@stoplight/markdown-viewer": "^5.4.6",
"@stoplight/markdown-viewer": "^5.4.7",
"@stoplight/mosaic": "^1.19.1",
"@stoplight/mosaic-code-editor": "^1.19.1",
"@stoplight/mosaic-code-viewer": "^1.19.1",
Expand Down
6 changes: 3 additions & 3 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": "1.7.1",
"version": "1.7.2",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -59,8 +59,8 @@
},
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^5.10.2",
"@stoplight/elements-core": "~7.5.17",
"@stoplight/markdown-viewer": "^5.4.6",
"@stoplight/elements-core": "~7.5.18",
"@stoplight/markdown-viewer": "^5.4.7",
"@stoplight/mosaic": "^1.16.2",
"@stoplight/path": "^1.3.2",
"@stoplight/types": "^13.0.0",
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": "7.5.17",
"version": "7.5.18",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -58,7 +58,7 @@
},
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@stoplight/elements-core": "~7.5.17",
"@stoplight/elements-core": "~7.5.18",
"@stoplight/http-spec": "^5.1.0",
"@stoplight/json": "^3.18.0",
"@stoplight/mosaic": "^1.16.2",
Expand Down
220 changes: 220 additions & 0 deletions packages/elements/src/components/API/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,226 @@ describe('computeTagGroups', () => {
const serviceNode = transformOasToServiceNode(apiDocument);
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({ groups: [], ungrouped: [] });
});

it('leaves tag casing unchanged', () => {
const apiDocument: OpenAPIObject = {
openapi: '3.0.0',
info: {
title: 'some api',
version: '1.0.0',
description: 'some description',
},
tags: [
{
name: 'Beta',
},
{
name: 'alpha',
},
],
paths: {
'/a': {
get: {
tags: ['alpha'],
},
},
'/b': {
get: {
tags: ['Beta'],
},
},
},
};

const serviceNode = transformOasToServiceNode(apiDocument);
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
groups: [
{
title: 'Beta',
items: [
{
type: 'http_operation',
uri: '/paths/b/get',
data: {
id: '2b447d075652c',
method: 'get',
path: '/b',
responses: [],
servers: [],
request: {
body: {
contents: [],
id: '1b5f96cfcd9cb',
},
headers: [],
query: [],
cookie: [],
path: [],
},
tags: [
{
name: 'Beta',
id: 'c028e10befb64',
},
],
security: [],
extensions: {},
},
name: '/b',
tags: ['Beta'],
},
],
},
{
title: 'alpha',
items: [
{
type: 'http_operation',
uri: '/paths/a/get',
data: {
id: '2b547d0756761',
method: 'get',
path: '/a',
responses: [],
servers: [],
request: {
body: {
contents: [],
id: 'c9a24d63f1884',
},
headers: [],
query: [],
cookie: [],
path: [],
},
tags: [
{
id: '7d65d096f3728',
name: 'alpha',
},
],
security: [],
extensions: {},
},
name: '/a',
tags: ['alpha'],
},
],
},
],
ungrouped: [],
});
});

it('matches mixed tag casing', () => {
const apiDocument: OpenAPIObject = {
openapi: '3.0.0',
info: {
title: 'some api',
version: '1.0.0',
description: 'some description',
},
tags: [
{
name: 'Beta',
},
{
name: 'alpha',
},
],
paths: {
'/a': {
get: {
tags: ['alpha'],
},
},
'/b': {
get: {
tags: ['beta'],
},
},
},
};

const serviceNode = transformOasToServiceNode(apiDocument);
expect(serviceNode ? computeTagGroups(serviceNode) : null).toEqual({
groups: [
{
title: 'Beta',
items: [
{
type: 'http_operation',
uri: '/paths/b/get',
data: {
id: '2b447d075652c',
method: 'get',
path: '/b',
responses: [],
servers: [],
request: {
body: {
contents: [],
id: '1b5f96cfcd9cb',
},
headers: [],
query: [],
cookie: [],
path: [],
},
tags: [
{
id: 'e01820f4e85ed',
name: 'beta',
},
],
security: [],
extensions: {},
},
name: '/b',
tags: ['beta'],
},
],
},
{
title: 'alpha',
items: [
{
type: 'http_operation',
uri: '/paths/a/get',
data: {
id: '2b547d0756761',
method: 'get',
path: '/a',
responses: [],
servers: [],
request: {
body: {
contents: [],
id: 'c9a24d63f1884',
},
headers: [],
query: [],
cookie: [],
path: [],
},
tags: [
{
id: '7d65d096f3728',
name: 'alpha',
},
],
security: [],
extensions: {},
},
name: '/a',
tags: ['alpha'],
},
],
},
],
ungrouped: [],
});
});
});

describe('computeAPITree', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/elements/src/components/API/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const computeTagGroups = (serviceNode: ServiceNode) => {
if (groupsByTagId[tagId]) {
groupsByTagId[tagId].items.push(node);
} else {
const serviceTagName = lowerCaseServiceTags.find(tn => tn === tagId);
const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId);
const serviceTagName = serviceNode.tags[serviceTagIndex];
groupsByTagId[tagId] = {
title: serviceTagName || tagName,
items: [node],
Expand Down

0 comments on commit 351474e

Please sign in to comment.