From 63ee245d3d5d4521d45bbfdbee0f52f296cd46d8 Mon Sep 17 00:00:00 2001 From: Freek van Rijt Date: Thu, 4 Apr 2024 14:14:24 +0200 Subject: [PATCH 01/41] feat(open-api): add open-api typescript types closes INT-407 --- package.json | 1 + yarn.lock | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/package.json b/package.json index 519e2972..c0923698 100755 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "markdown-it-multimd-table": "^4.1.3", "mock-fs": "^5.1.2", "only-allow": "^1.1.1", + "openapi-types": "^12.1.3", "plop": "^4.0.0", "postcss-import": "^15.1.0", "prettier": "^2.8.8", diff --git a/yarn.lock b/yarn.lock index 5da7bf24..900e3b67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1002,6 +1002,7 @@ __metadata: markdown-it-multimd-table: ^4.1.3 mock-fs: ^5.1.2 only-allow: ^1.1.1 + openapi-types: ^12.1.3 plop: ^4.0.0 postcss-import: ^15.1.0 prettier: ^2.8.8 @@ -7480,6 +7481,13 @@ __metadata: languageName: node linkType: hard +"openapi-types@npm:^12.1.3": + version: 12.1.3 + resolution: "openapi-types@npm:12.1.3" + checksum: 7fa5547f87a58d2aa0eba6e91d396f42d7d31bc3ae140e61b5d60b47d2fd068b48776f42407d5a8da7280cf31195aa128c2fc285e8bb871d1105edee5647a0bb + languageName: node + linkType: hard + "opener@npm:^1.5.1": version: 1.5.2 resolution: "opener@npm:1.5.2" From 09053b84ba558f0ee650194b016504166e354b4b Mon Sep 17 00:00:00 2001 From: Freek van Rijt Date: Thu, 4 Apr 2024 14:20:55 +0200 Subject: [PATCH 02/41] feat(open-api): add display of base open-api info and component structure closes INT-407 --- .../client/components/global/OpenApi.vue | 24 +++++++++++++++++++ .../client/components/global/OpenApiInfo.vue | 17 +++++++++++++ .../theme/client/components/global/index.ts | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 src/.vuepress/theme/client/components/global/OpenApi.vue create mode 100644 src/.vuepress/theme/client/components/global/OpenApiInfo.vue diff --git a/src/.vuepress/theme/client/components/global/OpenApi.vue b/src/.vuepress/theme/client/components/global/OpenApi.vue new file mode 100644 index 00000000..20c9cc6c --- /dev/null +++ b/src/.vuepress/theme/client/components/global/OpenApi.vue @@ -0,0 +1,24 @@ + + + diff --git a/src/.vuepress/theme/client/components/global/OpenApiInfo.vue b/src/.vuepress/theme/client/components/global/OpenApiInfo.vue new file mode 100644 index 00000000..419e98b0 --- /dev/null +++ b/src/.vuepress/theme/client/components/global/OpenApiInfo.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/.vuepress/theme/client/components/global/index.ts b/src/.vuepress/theme/client/components/global/index.ts index fc4ccbdd..96cf0ace 100644 --- a/src/.vuepress/theme/client/components/global/index.ts +++ b/src/.vuepress/theme/client/components/global/index.ts @@ -62,3 +62,5 @@ export {default as Shield} from './Shield'; export {default as Stack} from './Stack.vue'; export {default as TeamMember} from './TeamMember.vue'; + +export {default as OpenApi} from './OpenApi.vue'; From ecc3814442cc0c795547d274bfb69adc2b586268 Mon Sep 17 00:00:00 2001 From: Freek van Rijt Date: Thu, 4 Apr 2024 14:21:55 +0200 Subject: [PATCH 03/41] feat(open-api): add display of (example) responses and base path information for open-api closes INT-407 --- .../client/components/global/OpenApiPath.vue | 35 +++++++++++++ .../components/global/OpenApiResponses.vue | 50 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/.vuepress/theme/client/components/global/OpenApiPath.vue create mode 100644 src/.vuepress/theme/client/components/global/OpenApiResponses.vue diff --git a/src/.vuepress/theme/client/components/global/OpenApiPath.vue b/src/.vuepress/theme/client/components/global/OpenApiPath.vue new file mode 100644 index 00000000..de946c1c --- /dev/null +++ b/src/.vuepress/theme/client/components/global/OpenApiPath.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/.vuepress/theme/client/components/global/OpenApiResponses.vue b/src/.vuepress/theme/client/components/global/OpenApiResponses.vue new file mode 100644 index 00000000..66812369 --- /dev/null +++ b/src/.vuepress/theme/client/components/global/OpenApiResponses.vue @@ -0,0 +1,50 @@ + + + From 07481fa55c32326f57a2b77409901fe914bc3242 Mon Sep 17 00:00:00 2001 From: Freek van Rijt Date: Thu, 4 Apr 2024 15:43:47 +0200 Subject: [PATCH 04/41] feat(open-api): improve display of open-api operation details improves display of the path/method and adds placeholder security details closes INT-407 --- .../components/global/OpenApiOperation.vue | 40 +++++++++++++++++++ .../client/components/global/OpenApiPath.vue | 12 ++++-- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/.vuepress/theme/client/components/global/OpenApiOperation.vue diff --git a/src/.vuepress/theme/client/components/global/OpenApiOperation.vue b/src/.vuepress/theme/client/components/global/OpenApiOperation.vue new file mode 100644 index 00000000..cb96195f --- /dev/null +++ b/src/.vuepress/theme/client/components/global/OpenApiOperation.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/.vuepress/theme/client/components/global/OpenApiPath.vue b/src/.vuepress/theme/client/components/global/OpenApiPath.vue index de946c1c..4760625d 100644 --- a/src/.vuepress/theme/client/components/global/OpenApiPath.vue +++ b/src/.vuepress/theme/client/components/global/OpenApiPath.vue @@ -1,16 +1,20 @@ diff --git a/src/.vuepress/theme/client/components/global/OpenApiExample.vue b/src/.vuepress/theme/client/components/global/OpenApiExample.vue index 0086ba2b..7a465074 100644 --- a/src/.vuepress/theme/client/components/global/OpenApiExample.vue +++ b/src/.vuepress/theme/client/components/global/OpenApiExample.vue @@ -24,6 +24,7 @@ import {computed} from 'vue'; import {type OpenAPIV3_1 as OpenApiType} from 'openapi-types'; import Markdown from '@mptheme/client/components/global/Markdown.vue'; import CodeBlock from './CodeBlock.vue'; +import { formatExample } from '@mptheme/client/utils/openApiHelpers'; const props = defineProps<{ title?: string; @@ -43,12 +44,6 @@ const formattedExample = computed(() => { // Check the formattedExample for linebreaks, if it has those, it's a multiline string const isMultilineString = computed(() => formattedExample.value?.includes('\n')); -function formatExample(example: unknown): string { - const spacing = 2; - - return JSON.stringify(example, null, spacing); -} - // Guard to check if example is an Example object const isExampleObject = (example: unknown): example is OpenApiType.ExampleObject => { return !!example && typeof example === 'object' && 'value' in example; diff --git a/src/.vuepress/theme/client/components/global/OpenApiRequestParam.vue b/src/.vuepress/theme/client/components/global/OpenApiRequestParam.vue index b517fe4a..503ba467 100644 --- a/src/.vuepress/theme/client/components/global/OpenApiRequestParam.vue +++ b/src/.vuepress/theme/client/components/global/OpenApiRequestParam.vue @@ -10,9 +10,9 @@ {{ flag }} + :key="flag"> + {{ flag }} + @@ -63,6 +60,10 @@ const props = defineProps<{ parameter: OpenApiType.ParameterObject; }>(); +function schemaHasDescription(schema: OpenApiType.SchemaObject | undefined): boolean { + return !!(schema && 'description' in schema && schema.description?.length); +} + const flags = computed(() => { const arr: string[] = []; diff --git a/src/.vuepress/theme/client/components/global/OpenApiResponses.vue b/src/.vuepress/theme/client/components/global/OpenApiResponses.vue index dd5590e6..3178d47b 100644 --- a/src/.vuepress/theme/client/components/global/OpenApiResponses.vue +++ b/src/.vuepress/theme/client/components/global/OpenApiResponses.vue @@ -1,5 +1,5 @@ diff --git a/src/.vuepress/theme/client/components/global/OpenApiSecurityRequirements.vue b/src/.vuepress/theme/client/components/global/OpenApiSecurityRequirements.vue index e2c9b995..d605387a 100644 --- a/src/.vuepress/theme/client/components/global/OpenApiSecurityRequirements.vue +++ b/src/.vuepress/theme/client/components/global/OpenApiSecurityRequirements.vue @@ -1,5 +1,5 @@