Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 9248a7e

Browse files
committed
start building a new swagger ui
1 parent 0f97470 commit 9248a7e

28 files changed

+22285
-66
lines changed

example/src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const storeRouter = require('./routes/store');
88
const userRouter = require('./routes/user');
99

1010
const app = express();
11-
const PORT = 3000;
11+
const PORT = 4000;
1212

1313
// Body parsing.
1414
app.use(express.json());

example/src/routes/pet.js

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,6 @@ const { Router } = require('express');
22

33
const router = Router();
44

5-
/**
6-
* GET /pet/{petId}
7-
* @tag pet
8-
* @summary Find pet by ID
9-
* @description Returns a single pet
10-
* @operationId getPetById
11-
* @pathParam {int64} petId - ID of pet to return
12-
* @response 200 - successful operation
13-
* @responseContent {Pet} 200.application/json
14-
* @responseContent {Pet} 200.application/xml
15-
* @response 400 - Invalid ID supplied
16-
* @response 404 - Pet not found
17-
* @security ApiKey
18-
*/
19-
router.get('/:petId', async (req, res, next) => {
20-
res.end();
21-
});
22-
23-
/**
24-
* POST /pet/{petId}
25-
* @tag pet
26-
* @summary Updates a pet in the store with form data
27-
* @operationId updatePetWithForm
28-
* @pathParam {int64} petId - ID of pet that needs to be updated
29-
* @bodyContent {UpdatePetObject} application/x-www-form-urlencoded
30-
* @response 405 - Invalid input
31-
* @security PetstoreAuth.write:pets
32-
* @security PetstoreAuth.read:pets
33-
*/
34-
router.post('/:petId', async (req, res, next) => {
35-
res.end();
36-
});
37-
38-
/**
39-
* DELETE /pet/{petId}
40-
* @tag pet
41-
* @summary Deletes a pet
42-
* @operationId deletePet
43-
* @headerParam {string} [apikey]
44-
* @pathParam {int64} petId - Pet id to delete
45-
* @response 400 - Invalid ID supplied
46-
* @response 404 - Pet not found
47-
* @security PetstoreAuth.write:pets
48-
* @security PetstoreAuth.read:pets
49-
*/
50-
router.delete('/:petId', async (req, res, next) => {
51-
res.end();
52-
});
53-
54-
/**
55-
* POST /pet/{petId}/uploadImage
56-
* @tag pet
57-
* @summary uploads an image
58-
* @operationId uploadFile
59-
* @pathParam {int64} petId - ID of pet to update
60-
* @bodyContent {UploadPetImageObject} multipart/form-data
61-
* @response 200 - successful operation
62-
* @responseContent {ApiResponse} 200.application/json
63-
* @security PetstoreAuth.write:pets
64-
* @security PetstoreAuth.read:pets
65-
*/
66-
router.post('/:petId/uploadImage', async (req, res, next) => {
67-
res.end();
68-
});
69-
705
/**
716
* POST /pet
727
* @tag pet
@@ -139,4 +74,76 @@ router.get('/findByTags', async (req, res, next) => {
13974
res.end();
14075
});
14176

77+
/**
78+
* GET /pet/{petId}
79+
* @tag pet
80+
* @summary Find pet by ID
81+
* @description Returns a single pet
82+
* @operationId getPetById
83+
* @pathParam {int64} petId - ID of pet to return
84+
* @response 200 - successful operation
85+
* @responseContent {Pet} 200.application/json
86+
* @responseContent {Pet} 200.application/xml
87+
* @response 400 - Invalid ID supplied
88+
* @response 404 - Pet not found
89+
* @security ApiKey
90+
*/
91+
router.get('/:petId', async (req, res, next) => {
92+
res.format({
93+
'application/xml': () => {
94+
res.send(`<pet><id>${req.params.petId}</id></pet>`);
95+
},
96+
'application/json': () => {
97+
res.send({ id: req.params.petId });
98+
},
99+
});
100+
});
101+
102+
/**
103+
* POST /pet/{petId}
104+
* @tag pet
105+
* @summary Updates a pet in the store with form data
106+
* @operationId updatePetWithForm
107+
* @pathParam {int64} petId - ID of pet that needs to be updated
108+
* @bodyContent {UpdatePetObject} application/x-www-form-urlencoded
109+
* @response 405 - Invalid input
110+
* @security PetstoreAuth.write:pets
111+
* @security PetstoreAuth.read:pets
112+
*/
113+
router.post('/:petId', async (req, res, next) => {
114+
res.end();
115+
});
116+
117+
/**
118+
* DELETE /pet/{petId}
119+
* @tag pet
120+
* @summary Deletes a pet
121+
* @operationId deletePet
122+
* @headerParam {string} [apikey]
123+
* @pathParam {int64} petId - Pet id to delete
124+
* @response 400 - Invalid ID supplied
125+
* @response 404 - Pet not found
126+
* @security PetstoreAuth.write:pets
127+
* @security PetstoreAuth.read:pets
128+
*/
129+
router.delete('/:petId', async (req, res, next) => {
130+
res.end();
131+
});
132+
133+
/**
134+
* POST /pet/{petId}/uploadImage
135+
* @tag pet
136+
* @summary uploads an image
137+
* @operationId uploadFile
138+
* @pathParam {int64} petId - ID of pet to update
139+
* @bodyContent {UploadPetImageObject} multipart/form-data
140+
* @response 200 - successful operation
141+
* @responseContent {ApiResponse} 200.application/json
142+
* @security PetstoreAuth.write:pets
143+
* @security PetstoreAuth.read:pets
144+
*/
145+
router.post('/:petId/uploadImage', async (req, res, next) => {
146+
res.end();
147+
});
148+
142149
module.exports = router;

openapi-ui/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

openapi-ui/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

openapi-ui/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `yarn start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `yarn test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `yarn build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `yarn eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).
45+
46+
### Code Splitting
47+
48+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49+
50+
### Analyzing the Bundle Size
51+
52+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53+
54+
### Making a Progressive Web App
55+
56+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57+
58+
### Advanced Configuration
59+
60+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61+
62+
### Deployment
63+
64+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65+
66+
### `yarn build` fails to minify
67+
68+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

openapi-ui/jsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src"
4+
},
5+
"include": ["src"]
6+
}

openapi-ui/package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "openapi-ui",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@docusaurus/core": "^2.0.0-alpha.40",
7+
"@docusaurus/theme-classic": "^2.0.0-alpha.37",
8+
"@monaco-editor/react": "^3.3.1",
9+
"@testing-library/jest-dom": "^4.2.4",
10+
"@testing-library/react": "^9.3.2",
11+
"@testing-library/user-event": "^7.1.2",
12+
"query-string": "^6.12.1",
13+
"react": "^16.13.1",
14+
"react-dom": "^16.13.1",
15+
"react-magic-dropzone": "^1.0.1",
16+
"react-monaco-editor": "^0.36.0",
17+
"react-router-dom": "^5.2.0",
18+
"react-scripts": "3.4.1"
19+
},
20+
"scripts": {
21+
"start": "react-scripts start",
22+
"build": "react-scripts build",
23+
"test": "react-scripts test",
24+
"eject": "react-scripts eject"
25+
},
26+
"proxy": "http://localhost:4000",
27+
"eslintConfig": {
28+
"extends": "react-app"
29+
},
30+
"browserslist": {
31+
"production": [
32+
">0.2%",
33+
"not dead",
34+
"not op_mini all"
35+
],
36+
"development": [
37+
"last 1 chrome version",
38+
"last 1 firefox version",
39+
"last 1 safari version"
40+
]
41+
}
42+
}

openapi-ui/public/favicon.ico

3.08 KB
Binary file not shown.

openapi-ui/public/index.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en" data-theme="dark">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>React App</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

openapi-ui/public/logo192.png

5.22 KB
Loading

0 commit comments

Comments
 (0)