From 204fd8533cc5d2eb53aeba7f57bbfe488bf339b6 Mon Sep 17 00:00:00 2001 From: freisenhauer Date: Wed, 3 Jul 2024 11:43:04 +0200 Subject: [PATCH] Yaml examples (#58) * Bump @mittwald/flow-react-components Bumps [@mittwald/flow-react-components](https://github.com/mittwald/flow) from 0.1.0-alpha.150 to 0.1.0-alpha.153. - [Release notes](https://github.com/mittwald/flow/releases) - [Changelog](https://github.com/mittwald/flow/blob/main/CHANGELOG.md) - [Commits](https://github.com/mittwald/flow/compare/0.1.0-alpha.150...0.1.0-alpha.153) --- updated-dependencies: - dependency-name: "@mittwald/flow-react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump tsx from 4.11.2 to 4.15.7 Bumps [tsx](https://github.com/privatenumber/tsx) from 4.11.2 to 4.15.7. - [Release notes](https://github.com/privatenumber/tsx/releases) - [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs) - [Commits](https://github.com/privatenumber/tsx/compare/v4.11.2...v4.15.7) --- updated-dependencies: - dependency-name: tsx dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump @types/lodash from 4.17.4 to 4.17.5 Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.17.4 to 4.17.5. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash) --- updated-dependencies: - dependency-name: "@types/lodash" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Revamp tag index pages * Remove autogenerated category indexes * Operation links should respect API version * Display doccards in multiple columns; rely less on generated markdown * Formatting * Also add new reference index page * Fix duplicate reference index document * Bump @mittwald/flow-react-components Bumps [@mittwald/flow-react-components](https://github.com/mittwald/flow) from 0.1.0-alpha.153 to 0.1.0-alpha.155. - [Release notes](https://github.com/mittwald/flow/releases) - [Changelog](https://github.com/mittwald/flow/blob/main/CHANGELOG.md) - [Commits](https://github.com/mittwald/flow/compare/0.1.0-alpha.153...0.1.0-alpha.155) --- updated-dependencies: - dependency-name: "@mittwald/flow-react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Contextual help should come *after* the element * Use "plain" variant for copy button * Add option to customize API definitions with custom descriptions * Bump @mittwald/flow-react-components Bumps [@mittwald/flow-react-components](https://github.com/mittwald/flow) from 0.1.0-alpha.155 to 0.1.0-alpha.156. - [Release notes](https://github.com/mittwald/flow/releases) - [Changelog](https://github.com/mittwald/flow/blob/main/CHANGELOG.md) - [Commits](https://github.com/mittwald/flow/compare/0.1.0-alpha.155...0.1.0-alpha.156) --- updated-dependencies: - dependency-name: "@mittwald/flow-react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Add option to override code examples * Add option to override tag index pages * Fix bug in OperationUsage, when no custom tabs were passed * Document customization options * Provide translations for menu items and index pages * Make admonitions use InlineAlert component * Use OperationDocCard for operation references * Use specialized components to link to operations * Update translations * Bump @mittwald/flow-react-components Bumps [@mittwald/flow-react-components](https://github.com/mittwald/flow) from 0.1.0-alpha.156 to 0.1.0-alpha.160. - [Release notes](https://github.com/mittwald/flow/releases) - [Changelog](https://github.com/mittwald/flow/blob/main/CHANGELOG.md) - [Commits](https://github.com/mittwald/flow/compare/0.1.0-alpha.156...0.1.0-alpha.160) --- updated-dependencies: - dependency-name: "@mittwald/flow-react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bring intro page up-to-date * Fix typo * Add missing german translation for PHP SDK page * Add OperationExample component to render example API calls * Sort API tags & operations deterministically * Refactor Schema + SchemaExample components * Formatting * Add translations for tab titles * Add option to include raw JSON schema * Use new SchemaWithExample component where possible * Bump @mittwald/flow-react-components Bumps [@mittwald/flow-react-components](https://github.com/mittwald/flow) from 0.1.0-alpha.160 to 0.1.0-alpha.163. - [Release notes](https://github.com/mittwald/flow/releases) - [Changelog](https://github.com/mittwald/flow/blob/main/CHANGELOG.md) - [Commits](https://github.com/mittwald/flow/compare/0.1.0-alpha.160...0.1.0-alpha.163) --- updated-dependencies: - dependency-name: "@mittwald/flow-react-components" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump @types/lodash from 4.17.5 to 4.17.6 Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.17.5 to 4.17.6. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash) --- updated-dependencies: - dependency-name: "@types/lodash" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump typescript from 5.5.2 to 5.5.3 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.5.2 to 5.5.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.5.2...v5.5.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump tsx from 4.15.7 to 4.16.0 Bumps [tsx](https://github.com/privatenumber/tsx) from 4.15.7 to 4.16.0. - [Release notes](https://github.com/privatenumber/tsx/releases) - [Changelog](https://github.com/privatenumber/tsx/blob/master/release.config.cjs) - [Commits](https://github.com/privatenumber/tsx/compare/v4.15.7...v4.16.0) --- updated-dependencies: - dependency-name: tsx dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Fix display of array items in Schema component This commit changes the display of array items so that the actual sub-schema of said items is displayed. This reduces the asthetic annoyance when an empty "Array[]" schema is displayed (when no sub-schema is given), and also fixes a bug where the description of array items was not rendered at all. * Add option to use YAML encoding for schema examples * Extract schema format into common data type * use yaml examples for extension resources --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Martin Helmich Co-authored-by: Frederic Reisenhauer --- docs/contributing/reference/contributor.mdx | 1 + docs/contributing/reference/extensions.mdx | 1 + docs/contributing/reference/oauth2.mdx | 1 + docs/contributing/reference/webhooks.mdx | 4 + package-lock.json | 380 +----------------- package.json | 2 +- .../openapi/OperationInputValue.tsx | 6 +- src/components/openapi/Schema.tsx | 2 + src/components/openapi/SchemaExample.tsx | 19 +- src/components/openapi/SchemaWithExample.tsx | 37 +- 10 files changed, 74 insertions(+), 379 deletions(-) diff --git a/docs/contributing/reference/contributor.mdx b/docs/contributing/reference/contributor.mdx index 3c9b3053..68ac763c 100644 --- a/docs/contributing/reference/contributor.mdx +++ b/docs/contributing/reference/contributor.mdx @@ -10,6 +10,7 @@ Die benötigten und erlaubten Attribute sind in folgendem Schema beschrieben. =12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/darwin-arm64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", @@ -2971,294 +2907,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@formatjs/ecma402-abstract": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-2.0.0.tgz", @@ -5642,15 +5290,6 @@ "node": ">=14.16" } }, - "node_modules/@tabler/icons": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-3.6.0.tgz", - "integrity": "sha512-Zv0Ofc64RCMpZ2F8CvsWAphrSjerx5hEErt/RMmE+W8r4E5l5Lizi+My9KbbZQ4NyAtrtrOX80OY1oROZrRzEA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/codecalm" - } - }, "node_modules/@tabler/icons-react": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/@tabler/icons-react/-/icons-react-3.6.0.tgz", @@ -5666,6 +5305,15 @@ "react": ">= 16" } }, + "node_modules/@tabler/icons-react/node_modules/@tabler/icons": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-3.6.0.tgz", + "integrity": "sha512-Zv0Ofc64RCMpZ2F8CvsWAphrSjerx5hEErt/RMmE+W8r4E5l5Lizi+My9KbbZQ4NyAtrtrOX80OY1oROZrRzEA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/codecalm" + } + }, "node_modules/@tanstack/react-table": { "version": "8.17.3", "resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.17.3.tgz", @@ -18315,12 +17963,12 @@ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/tsx": { - "version": "4.15.7", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.15.7.tgz", - "integrity": "sha512-u3H0iSFDZM3za+VxkZ1kywdCeHCn+8/qHQS1MNoO2sONDgD95HlWtt8aB23OzeTmFP9IU4/8bZUdg58Uu5J4cg==", + "version": "4.16.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.16.0.tgz", + "integrity": "sha512-MPgN+CuY+4iKxGoJNPv+1pyo5YWZAQ5XfsyobUG+zoKG7IkvCPLZDEyoIb8yLS2FcWci1nlxAqmvPlFWD5AFiQ==", "dev": true, "dependencies": { - "esbuild": "~0.21.4", + "esbuild": "~0.21.5", "get-tsconfig": "^4.7.5" }, "bin": { diff --git a/package.json b/package.json index 0e38194b..97a556a7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "camelcase": "^8.0.0", "lodash": "^4.17.21", "prettier": "^3.3.2", - "tsx": "^4.15.7", + "tsx": "^4.16.0", "typescript": "^5.5.3" }, "browserslist": { diff --git a/src/components/openapi/OperationInputValue.tsx b/src/components/openapi/OperationInputValue.tsx index b5e484e8..cc7708c4 100644 --- a/src/components/openapi/OperationInputValue.tsx +++ b/src/components/openapi/OperationInputValue.tsx @@ -34,7 +34,7 @@ export function ArrayValue({ schema }: { schema: OpenAPIV3.SchemaObject }) { Array[
{body}
- +
]
@@ -58,6 +58,8 @@ export function PropertyValue({ body = {schema.description}; } + const hasSubSchema = schema.properties || schema.additionalProperties || schema.items; + return (
  • @@ -67,7 +69,7 @@ export function PropertyValue({ {requiredOrOptional}
    {body}
    - + {hasSubSchema && }
  • ); } diff --git a/src/components/openapi/Schema.tsx b/src/components/openapi/Schema.tsx index d8010582..845e24b3 100644 --- a/src/components/openapi/Schema.tsx +++ b/src/components/openapi/Schema.tsx @@ -92,4 +92,6 @@ export default function Schema({ schema }: Props) { if (schema.type === "array") { return ; } + + return ; } diff --git a/src/components/openapi/SchemaExample.tsx b/src/components/openapi/SchemaExample.tsx index 4ae2ce95..22fcbb3a 100644 --- a/src/components/openapi/SchemaExample.tsx +++ b/src/components/openapi/SchemaExample.tsx @@ -1,12 +1,16 @@ import { OpenAPIV3 } from "openapi-types"; import CodeBlock from "@theme/CodeBlock"; import { generateSchemaExample } from "@site/src/openapi/generateSchemaExample"; +import * as yaml from "yaml"; interface Props { title?: string; schema: OpenAPIV3.SchemaObject; + format?: ExampleFormat; } +export type ExampleFormat = "json" | "yaml"; + /** * This component renders an example of a given schema. * @@ -16,8 +20,13 @@ interface Props { * * @param schema The schema for which to generate an example * @param title Optional title for the example + * @param format Optional format for the example (json or yaml; will default to json) */ -export default function SchemaExample({ schema, title }: Props) { +export default function SchemaExample({ + schema, + title, + format = "json", +}: Props) { if (schema.oneOf) { return schema.oneOf.map((s, idx) => ( )); } + const example = generateSchemaExample(schema); + const rendered = + format === "yaml" + ? yaml.stringify(example) + : JSON.stringify(example, null, 2); + return ( - {JSON.stringify(example, null, 2)} + {rendered} ); } diff --git a/src/components/openapi/SchemaWithExample.tsx b/src/components/openapi/SchemaWithExample.tsx index a88e85ed..c685c70d 100644 --- a/src/components/openapi/SchemaWithExample.tsx +++ b/src/components/openapi/SchemaWithExample.tsx @@ -1,13 +1,16 @@ import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import Schema from "@site/src/components/openapi/Schema"; -import SchemaExample from "@site/src/components/openapi/SchemaExample"; +import SchemaExample, { + ExampleFormat, +} from "@site/src/components/openapi/SchemaExample"; import { OpenAPIV3 } from "openapi-types"; import { translate } from "@docusaurus/Translate"; import CodeBlock from "@theme/CodeBlock"; interface Props { schema: OpenAPIV3.SchemaObject; + format?: ExampleFormat; withRawJSONSchema?: boolean; } @@ -16,21 +19,39 @@ interface Props { * * @param schema The schema to render and to generate an example for * @param withRawJSONSchema Whether to show the raw JSON schema in a tab + * @param format Optional format for the example (json or yaml) * @see Schema * @see SchemaExample */ -export default function SchemaWithExample({ schema, withRawJSONSchema }: Props) { +export default function SchemaWithExample({ + schema, + withRawJSONSchema, + format, +}: Props) { return ( - + - - + + - {withRawJSONSchema && - {JSON.stringify(schema, null, 2)} - } + {withRawJSONSchema && ( + + + {JSON.stringify(schema, null, 2)} + + + )} ); }