Skip to content

Commit

Permalink
🐛 fix swagger-ui-reac bug on build
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Apr 21, 2022
1 parent 393ae80 commit 931514e
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 70 deletions.
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"dev": "next dev",
"start": "next start"
},
"dependencies": {
Expand All @@ -13,11 +13,11 @@
"next-swagger-doc": "latest",
"react": "18.0.0",
"react-dom": "18.0.0",
"swagger-ui-react": "4.8.1"
"swagger-ui-react": "latest"
},
"devDependencies": {
"@types/node": "16.11.27",
"@types/react": "18.0.1",
"@types/react": "18.0.5",
"@types/react-dom": "18.0.1",
"@types/swagger-jsdoc": "6.0.1",
"eslint": "8.13.0",
Expand Down
10 changes: 7 additions & 3 deletions example/pages/api-doc.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { GetStaticProps, InferGetStaticPropsType } from 'next';

import dynamic from 'next/dynamic';
import { createSwaggerSpec } from 'next-swagger-doc';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';

const SwaggerUI = dynamic<{
spec: any;
}>(import('swagger-ui-react'), { ssr: false });

const ApiDoc = ({ spec }: InferGetStaticPropsType<typeof getStaticProps>) => {
return <SwaggerUI spec={spec} />;
};

export const getStaticProps: GetStaticProps = async () => {
export const getStaticProps: GetStaticProps = async ctx => {
const spec: Record<string, any> = createSwaggerSpec({
apiFolder: 'pages/api',
schemaFolders: ['models'],
Expand All @@ -20,6 +23,7 @@ export const getStaticProps: GetStaticProps = async () => {
},
},
});

return {
props: {
spec,
Expand Down
6 changes: 5 additions & 1 deletion example/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Head from 'next/head';

import SwaggerUI from 'swagger-ui-react';
import dynamic from 'next/dynamic';
import 'swagger-ui-react/swagger-ui.css';

const SwaggerUI = dynamic<{ url: string }>(import('swagger-ui-react'), {
ssr: false,
});

export default function Home() {
return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
Expand All @@ -27,4 +27,4 @@
"exclude": [
"node_modules"
]
}
}
16 changes: 8 additions & 8 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/react@18.0.1":
version "18.0.1"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.1.tgz#1b2e02fb7613212518733946e49fb963dfc66e19"
integrity sha512-VnWlrVgG0dYt+NqlfMI0yUYb8Rdl4XUROyH+c6gq/iFCiZ805Vi//26UW38DHnxQkbDhnrIWTBiy6oKZqL11cw==
"@types/react@18.0.5":
version "18.0.5"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.5.tgz#1a4d4b705ae6af5aed369dec22800b20f89f5301"
integrity sha512-UPxNGInDCIKlfqBrm8LDXYWNfLHwIdisWcsH5GpMyGjhEDLFgTtlRBaoWuCua9HcyuE0rMkmAeZ3FXV1pYLIYQ==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down Expand Up @@ -2340,10 +2340,10 @@ swagger-parser@10.0.2:
dependencies:
"@apidevtools/swagger-parser" "10.0.2"

swagger-ui-react@4.8.1:
version "4.8.1"
resolved "https://registry.yarnpkg.com/swagger-ui-react/-/swagger-ui-react-4.8.1.tgz#552c45696ad127173f1851e8e776e09fc86da7df"
integrity sha512-SB2y+eGb+gjNKQyrJuo80YK1y2uyIVVfiLO/orqBDpEtuLVzzuEls7afDTRKy4vW2eMjkmjaWPugT6RFBwe1TA==
swagger-ui-react@latest:
version "4.10.3"
resolved "https://registry.yarnpkg.com/swagger-ui-react/-/swagger-ui-react-4.10.3.tgz#72b7eb432f3e1ad09a81556af75d22ac3a66ae40"
integrity sha512-rxLVM8hv6aH+8BEJuyfejt2BweV2TLB8KiifE/8CAk96PoDyQeCTnLgivTdXIuDqdSSSajlzTq0ccw0QMYQbvA==
dependencies:
"@babel/runtime-corejs3" "^7.16.8"
"@braintree/sanitize-url" "=6.0.0"
Expand Down
81 changes: 41 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
{
"name": "next-swagger-doc",
"version": "0.2.1",
"keywords": [
"next-swagger",
"next-swagger-doc",
"nextjs",
"swagger"
],
"repository": {
"type": "git",
"url": "https://github.com/jellydn/next-swagger-doc"
},
"license": "MIT",
"author": "Huynh Duc Dung",
"type": "module",
"exports": {
"require": "./dist/index.js",
"import": "./dist/next-swagger-doc.esm.js"
},
"main": "dist/index.js",
"module": "dist/next-swagger-doc.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"engines": {
"node": ">=12"
},
"scripts": {
"start": "tsdx watch",
"analyze": "size-limit --why",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why",
"start": "tsdx watch",
"test": "tsdx test",
"vercel-build": "npx typedoc src/index.ts"
},
"peerDependencies": {
"next": ">=9"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
Expand All @@ -34,33 +46,10 @@
"singleQuote": true,
"trailingComma": "es5"
},
"name": "next-swagger-doc",
"keywords": [
"next-swagger",
"next-swagger-doc",
"nextjs",
"swagger"
],
"author": "Huynh Duc Dung",
"repository": {
"type": "git",
"url": "https://github.com/jellydn/next-swagger-doc"
},
"module": "dist/next-swagger-doc.esm.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/next-swagger-doc.esm.js"
"dependencies": {
"isarray": "^2.0.5",
"swagger-jsdoc": "^6.2.1"
},
"size-limit": [
{
"path": "dist/next-swagger-doc.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/next-swagger-doc.esm.js",
"limit": "10 KB"
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "7.0.8",
"@skypack/package-check": "0.2.2",
Expand All @@ -74,8 +63,20 @@
"typedoc": "0.22.15",
"typescript": "4.6.3"
},
"dependencies": {
"isarray": "^2.0.5",
"swagger-jsdoc": "^6.1.0"
}
}
"peerDependencies": {
"next": ">=9"
},
"engines": {
"node": ">=12"
},
"size-limit": [
{
"path": "dist/next-swagger-doc.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/next-swagger-doc.esm.js",
"limit": "10 KB"
}
]
}
21 changes: 8 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2073,15 +2073,10 @@ camelcase@^6.0.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==

caniuse-lite@^1.0.30001219:
version "1.0.30001271"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001271.tgz"
integrity sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA==

caniuse-lite@^1.0.30001283:
version "1.0.30001299"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001299.tgz#d753bf6444ed401eb503cbbe17aa3e1451b5a68c"
integrity sha512-iujN4+x7QzqA2NCSrS5VUy+4gLmRd4xv6vbBBsmfVqTx8bLAD8097euLqQgKxSVLvxjSDcvF1T/i9ocgnUFexw==
caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001283:
version "1.0.30001332"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz"
integrity sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -6240,10 +6235,10 @@ supports-hyperlinks@^2.0.0:
has-flag "^4.0.0"
supports-color "^7.0.0"

swagger-jsdoc@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/swagger-jsdoc/-/swagger-jsdoc-6.1.0.tgz#c2b86321f2c4dde8947b418fe8a4bc94431d5522"
integrity sha512-xgep5M8Gq31MxpCbQLvJZpNqHfGPfI+sILCzujZbEXIQp2COtkZgoGASs0gacRs4xHmLDH+GuMGdorPITSG4tA==
swagger-jsdoc@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/swagger-jsdoc/-/swagger-jsdoc-6.2.1.tgz#2f3f67c8433ae2c09e7e318d2f8fd9e09f0166b3"
integrity sha512-l2BwFf7wzNPb11+NRRy65X+kuHUGLb3ZuGFn6A8xDXXTu73YzJmCiy+LED/6QsOgPBPgO3u3sDEz6KuOHAlCtA==
dependencies:
commander "6.2.0"
doctrine "3.0.0"
Expand Down

2 comments on commit 931514e

@vercel
Copy link

@vercel vercel bot commented on 931514e Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 931514e Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.