-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecba977
commit 0a58545
Showing
12 changed files
with
1,305 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
id: | ||
slug: users-get | ||
--- | ||
|
||
``` | ||
GET /users | ||
``` | ||
|
||
**Returns a list of users.: **Optional extended description in CommonMark or HTML. | ||
|
||
## Parameters | ||
|
||
| name | in | type | required | description | | ||
| ---- | --- | ---- | -------- | ----------- | | ||
|
||
## Code Snippets | ||
|
||
```javascript title="Node + Native" | ||
const http = require("http"); | ||
|
||
const options = { | ||
method: "GET", | ||
hostname: "api.example.com", | ||
port: null, | ||
path: "/v1/users", | ||
headers: {}, | ||
}; | ||
|
||
const req = http.request(options, function (res) { | ||
const chunks = []; | ||
|
||
res.on("data", function (chunk) { | ||
chunks.push(chunk); | ||
}); | ||
|
||
res.on("end", function () { | ||
const body = Buffer.concat(chunks); | ||
console.log(body.toString()); | ||
}); | ||
}); | ||
|
||
req.end(); | ||
``` | ||
|
||
## Responses | ||
|
||
### 200 | ||
|
||
A JSON array of user names | ||
|
||
| Headers | | | ||
| ------------ | ---------------- | | ||
| content-type | application/json | | ||
|
||
**Example `response` for `application/json`** | ||
|
||
```json | ||
["string"] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
id: getUsers | ||
title: Returns a list of users. | ||
--- | ||
|
||
<!-- prettier-ignore-start --> | ||
|
||
export const Method = ({children, color}) => ( | ||
<span | ||
style={{ | ||
backgroundColor: color, | ||
borderRadius: '6px', | ||
color: '#fff', | ||
padding: '0.6rem 1.2rem', | ||
textTransform: 'uppercase', | ||
fontWeight: 'bold' | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
|
||
export const Path = ({children}) => ( | ||
<span | ||
style={{ | ||
borderRadius: '6px', | ||
color: '#000', | ||
paddingLeft: '0.8rem', | ||
textTransform: 'lowercase', | ||
fontWeight: 'bold', | ||
fontsSize: '1.2rem' | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
|
||
export const Url = ({children}) => { | ||
return ( | ||
<div | ||
style={{ | ||
marginBottom: '3rem', | ||
paddingTop: '1rem' | ||
}}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
<!-- prettier-ignore-end --> | ||
|
||
<Url> | ||
<Method color="#6b55b2">GET</Method><Path>{unescape(escape('/users'))}</Path> | ||
</Url> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
const convert = require('../dist').default; | ||
const bundler = require('../dist/bundler').default; | ||
const OpenAPISampler = require('openapi-sampler'); | ||
const convert = require("../dist").default; | ||
|
||
console.log(process.cwd()) | ||
/* | ||
bundler('example/petstore.json', './') | ||
.then(spec => { | ||
//console.log(OpenAPISampler.sample(spec.components.schemas.Pet, {}, spec)); | ||
// converts to markdown using default template | ||
convert("example/specs/simple.yaml", { | ||
outPath: "./example/build/md", | ||
snippetTargets: ["node"], | ||
prettierParser: "markdown", | ||
}) | ||
.then(() => { | ||
console.log(`File 'example/specs/simple.yaml' converted to markdown.`); | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
console.error(err); | ||
})*/ | ||
}); | ||
|
||
convert('example/petstore.json', { outPath: './build', snippetTargets: ["node", "python"] }) | ||
// converts to mdx using default template | ||
convert("example/specs/simple.yaml", { | ||
outPath: "./example/build/mdx", | ||
snippetTargets: ["shell", "python"], | ||
templatesPath: "example/templates/mdx", | ||
prettierParser: "markdown", | ||
}) | ||
.then(() => { | ||
console.log("Finished.") | ||
console.log(`File 'example/specs/simple.yaml' converted to mdx.`); | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
|
||
// converts a complex file | ||
convert("example/specs/petstore.json", { | ||
outPath: "./build", | ||
snippetTargets: ["node", "python"] | ||
}) | ||
.then(() => { | ||
console.log("Finished."); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
}, | ||
"servers": [ | ||
{ | ||
"url": "/api/v3" | ||
"url": "http://swagger.io/api/v3" | ||
} | ||
], | ||
"tags": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Sample API | ||
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML. | ||
version: 0.1.9 | ||
servers: | ||
- url: 'http://api.example.com/v1' | ||
description: Optional server description, e.g. Main (production) server | ||
|
||
paths: | ||
/users: | ||
get: | ||
summary: Returns a list of users. | ||
description: Optional extended description in CommonMark or HTML. | ||
operationId: getUsers | ||
parameters: [] | ||
responses: | ||
'200': # status code | ||
description: A JSON array of user names | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
id: {{method.operationId}} | ||
title: {{method.summary}} | ||
--- | ||
|
||
<!-- prettier-ignore-start --> | ||
{{{{rawBlock}}}} | ||
|
||
export const Method = ({children, color}) => ( | ||
<span | ||
style={{ | ||
backgroundColor: color, | ||
borderRadius: '6px', | ||
color: '#fff', | ||
padding: '0.6rem 1.2rem', | ||
textTransform: 'uppercase', | ||
fontWeight: 'bold' | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
|
||
export const Path = ({children}) => ( | ||
<span | ||
style={{ | ||
borderRadius: '6px', | ||
color: '#000', | ||
paddingLeft: '0.8rem', | ||
textTransform: 'lowercase', | ||
fontWeight: 'bold', | ||
fontsSize: '1.2rem' | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
|
||
export const Url = ({children}) => { | ||
return ( | ||
<div | ||
style={{ | ||
marginBottom: '3rem', | ||
paddingTop: '1rem' | ||
}}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
{{{{/rawBlock}}}} | ||
<!-- prettier-ignore-end --> | ||
|
||
<Url> | ||
<Method color="#6b55b2">{{httpMethod}}</Method><Path>{unescape(escape('{{path}}'))}</Path> | ||
</Url> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.