Skip to content

Commit 67afd17

Browse files
author
grignong
committed
feat: add swagger block
1 parent ba6cb61 commit 67afd17

10 files changed

+898
-160
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ dist-ssr
44
*.local
55
.yalc.lock
66
.yalc
7-
dist
7+
dist
8+
9+
# IDEs
10+
.idea

DOCUMENTATION.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GitHub Blocks Template
2+
3+
Use this repository as a starter template for building your own Blocks.
4+
## Quickstart
5+
6+
> 🛑 Currently, you must be flagged into the [GitHub Blocks Technical Preview](https://blocks.githubnext.com) in order to develop blocks. There is no "offline" development mode at this time.
7+
8+
Fork this repo using the [`Use this template`](https://github.com/githubnext/blocks-template/generate) button above:
9+
10+
!["Use this template" button](https://user-images.githubusercontent.com/8978670/144893319-5d45ab5c-12c0-42b4-99f8-97f658deb03b.png)
11+
12+
Then, clone _your_ repo (not [this one!](https://github.com/githubnext/blocks-template)) and get ready for action:
13+
14+
```bash
15+
yarn # install dependencies
16+
yarn start # start the dev server
17+
# Or use npm, pnpm, you know the drill
18+
```
19+
20+
When you visit [localhost:4000](https://localhost:4000) in your browser, you'll be
21+
redirected to the Blocks app, but your locally-developed blocks will appear in the block picker:
22+
23+
<img alt="Block picker" src="https://user-images.githubusercontent.com/56439/181648955-101b6567-3f9b-44b3-af99-7ef3ca6161b9.png" width="418" />
24+
25+
(if you're using Safari (or another browser that doesn't permit calling `http` URLs from an `https` page), run `yarn start-https` and visit [https://localhost:4000](https://localhost:4000) instead.)
26+
27+
This template includes one example File Block and one Folder Block. The dev server supports hot reloading, so make some changes, and see what they do!
28+
29+
## Under the hood
30+
31+
Currently, Blocks are [React](https://reactjs.org/) components. They have a well-defined contract with their surroundings, and receive a [fixed set of props](https://github.com/githubnext/blocks/blob/main/docs/Developing%20blocks/4%20API%20reference%20and%20types.md) when they are instantiated. They are developed in [TypeScript](https://www.typescriptlang.org/), and bundled with [Vite](https://vitejs.dev/).
32+
33+
## More Info
34+
35+
Visit [githubnext/blocks](https://blocks.githubnext.com/githubnext/blocks) for a full tutorial, documentation, and examples.
36+
37+
You should also join us in our discord! There's a [#blocks channel](https://discord.com/channels/735557230698692749/1039950186136469535) where you can connect with us and other folks who are building Blocks:
38+
39+
> 👋 https://discord.gg/githubnext
40+
## License
41+
42+
MIT
43+
44+
✌️ ❤️
45+
_GitHub Next_

README.md

+7-38
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,14 @@
1-
# GitHub Blocks Template
1+
# Kerhub Blocks
22

3-
Use this repository as a starter template for building your own Blocks.
4-
## Quickstart
3+
> GitHub Blocks are under technical preview
54
6-
> 🛑 Currently, you must be flagged into the [GitHub Blocks Technical Preview](https://blocks.githubnext.com) in order to develop blocks. There is no "offline" development mode at this time.
75

8-
Fork this repo using the [`Use this template`](https://github.com/githubnext/blocks-template/generate) button above:
6+
## Blocks
97

10-
!["Use this template" button](https://user-images.githubusercontent.com/8978670/144893319-5d45ab5c-12c0-42b4-99f8-97f658deb03b.png)
8+
### Swagger
119

12-
Then, clone _your_ repo (not [this one!](https://github.com/githubnext/blocks-template)) and get ready for action:
10+
Provides an UI interface for your yml/json swagger files.
1311

14-
```bash
15-
yarn # install dependencies
16-
yarn start # start the dev server
17-
# Or use npm, pnpm, you know the drill
18-
```
12+
## Technical documentation
1913

20-
When you visit [localhost:4000](https://localhost:4000) in your browser, you'll be
21-
redirected to the Blocks app, but your locally-developed blocks will appear in the block picker:
22-
23-
<img alt="Block picker" src="https://user-images.githubusercontent.com/56439/181648955-101b6567-3f9b-44b3-af99-7ef3ca6161b9.png" width="418" />
24-
25-
(if you're using Safari (or another browser that doesn't permit calling `http` URLs from an `https` page), run `yarn start-https` and visit [https://localhost:4000](https://localhost:4000) instead.)
26-
27-
This template includes one example File Block and one Folder Block. The dev server supports hot reloading, so make some changes, and see what they do!
28-
29-
## Under the hood
30-
31-
Currently, Blocks are [React](https://reactjs.org/) components. They have a well-defined contract with their surroundings, and receive a [fixed set of props](https://github.com/githubnext/blocks/blob/main/docs/Developing%20blocks/4%20API%20reference%20and%20types.md) when they are instantiated. They are developed in [TypeScript](https://www.typescriptlang.org/), and bundled with [Vite](https://vitejs.dev/).
32-
33-
## More Info
34-
35-
Visit [githubnext/blocks](https://blocks.githubnext.com/githubnext/blocks) for a full tutorial, documentation, and examples.
36-
37-
You should also join us in our discord! There's a [#blocks channel](https://discord.com/channels/735557230698692749/1039950186136469535) where you can connect with us and other folks who are building Blocks:
38-
39-
> 👋 https://discord.gg/githubnext
40-
## License
41-
42-
MIT
43-
44-
✌️ ❤️
45-
_GitHub Next_
14+
[Project Documentation](DOCUMENTATION.md)

blocks.config.json

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
[
22
{
33
"type": "file",
4-
"id": "file-block",
5-
"title": "Example File Block",
6-
"description": "A basic file block",
7-
"entry": "blocks/example-file-block/index.tsx",
8-
"matches": ["*"],
9-
"example_path": "https://github.com/facebook/react/blob/main/packages/react-dom/index.js"
10-
},
11-
{
12-
"type": "folder",
13-
"id": "folder-block",
14-
"title": "Example Folder Block",
15-
"description": "A basic folder block",
16-
"entry": "blocks/example-folder-block.tsx",
17-
"matches": ["*"],
18-
"example_path": "https://github.com/githubocto/flat"
4+
"id": "swagger",
5+
"title": "Swagger UI",
6+
"description": "Visualize APIs defined in Swagger 2.0 or OAS 3.0",
7+
"entry": "blocks/swagger/index.tsx",
8+
"matches": ["*.json", "*.yml"],
9+
"example_path": "https://github.com/gothinkster/realworld/blob/main/api/openapi.yml"
1910
}
2011
]

blocks/example-file-block/index.css

-3
This file was deleted.

blocks/example-file-block/index.tsx

-43
This file was deleted.

blocks/example-folder-block.tsx

-46
This file was deleted.

blocks/swagger/index.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { FileBlockProps } from "@githubnext/blocks";
2+
import SwaggerUI from 'swagger-ui-react';
3+
import 'swagger-ui-react/swagger-ui.css';
4+
5+
export default function (props: FileBlockProps) {
6+
const { content } = props;
7+
8+
return (
9+
<SwaggerUI spec={content} />
10+
);
11+
}

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "custom-block-template",
3-
"version": "0.0.0",
2+
"name": "kerhub-blocks",
3+
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
66
"start": "blocks start",
@@ -10,6 +10,10 @@
1010
"dependencies": {
1111
"@githubnext/blocks": "^2.3.5",
1212
"react": "^18.1.0",
13-
"react-dom": "^18.1.0"
13+
"react-dom": "^18.1.0",
14+
"swagger-ui-react": "^4.15.5"
15+
},
16+
"devDependencies": {
17+
"@types/swagger-ui-react": "^4.11.0"
1418
}
1519
}

0 commit comments

Comments
 (0)