mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-18 08:26:35 +00:00
add first version of tailwind docs
This commit is contained in:
123
generator/templates/ApiTemplate.ts
Normal file
123
generator/templates/ApiTemplate.ts
Normal file
@@ -0,0 +1,123 @@
|
||||
const template = `
|
||||
|
||||
|
||||
---
|
||||
|
||||
<% operations.forEach(function(operation){ %>
|
||||
|
||||
## <%- operation.summary %> {{ tag: '<%- operation.operation.toUpperCase() %>' , label: '<%- operation.path %>' }}
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
<%- operation.description %>
|
||||
<% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'path').length > 0){ %>
|
||||
#### Path Parameters
|
||||
<Properties>
|
||||
<% operation.parameters.filter((parameter) => parameter.in === 'path').forEach(function(parameter){ %>
|
||||
<Property name="<%- parameter.name %>" type="string" required=\{true\}>
|
||||
<%- parameter.description %>
|
||||
</Property>
|
||||
<% }); -%>
|
||||
</Properties>
|
||||
<% }; -%>
|
||||
<% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'query').length > 0){ %>
|
||||
#### Query Parameters
|
||||
<Properties>
|
||||
<% operation.parameters.filter((parameter) => parameter.in === 'query').forEach(function(parameter){ %>
|
||||
<Property name="<%- parameter.name %>" type="<%- parameter.schema.type %>" required=\{false\}>
|
||||
<%- parameter.description %>
|
||||
</Property>
|
||||
<% }); -%>
|
||||
</Properties>
|
||||
<% }; -%>
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
|
||||
#### Request-Body Parameters
|
||||
<Properties>
|
||||
<% schemas.get(operation.requestBody?.content['application/json'].schema.$ref.split('/').pop())?.parameters.forEach(function(parameter){ %>
|
||||
<Property name="<%- parameter.name %>" type="<%- parameter.type %>" required=\{<%- parameter.required %>\}
|
||||
<% if(parameter.enum){ %>
|
||||
enumList="<%- parameter.enum %>"
|
||||
<% }; -%>
|
||||
<% if(parameter.minimum){ %>
|
||||
min=\{<%- parameter.minimum %>\}
|
||||
<% }; -%>
|
||||
<% if(parameter.maximum){ %>
|
||||
max=\{<%- parameter.maximum %>\}
|
||||
<% }; -%>
|
||||
<% if(parameter.minLength){ %>
|
||||
minLen=\{<%- parameter.minLength %>\}
|
||||
<% }; -%>
|
||||
<% if(parameter.maxLength){ %>
|
||||
maxLen=\{<%- parameter.maxLength %>\}
|
||||
<% }; -%> >
|
||||
<%- parameter.description %>
|
||||
</Property>
|
||||
<% }); -%>
|
||||
</Properties>
|
||||
<% }; -%>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
<CodeGroup title="Request" tag="<%- operation.operation.toUpperCase() %>" label="<%- operation.path %>">
|
||||
\`\`\`bash {{ title: 'cURL' }}
|
||||
curl -X <%- operation.operation.toUpperCase() %> <%- operation.fullPath %> \\
|
||||
-H "Authorization: Bearer {token}" \\
|
||||
<% if(operation.responseList[0].content && operation.responseList[0].content['application/json']){ -%>
|
||||
-H 'Accept: application/json' \\<% }; %>
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%>
|
||||
-H 'Content-Type: application/json' \\
|
||||
--data-raw '<%- JSON.stringify(schemas.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.examples, null, 2) %>'<% }; %>
|
||||
\`\`\`
|
||||
|
||||
\`\`\`js
|
||||
import ApiClient from '@example/protocol-api'
|
||||
|
||||
const client = new ApiClient(token)
|
||||
|
||||
await client.contacts.update('WAz8eIbvDR60rouK', {
|
||||
display_name: 'UncleFrank',
|
||||
})
|
||||
\`\`\`
|
||||
|
||||
\`\`\`python
|
||||
from protocol_api import ApiClient
|
||||
|
||||
client = ApiClient(token)
|
||||
|
||||
client.contacts.update("WAz8eIbvDR60rouK", display_name="UncleFrank")
|
||||
\`\`\`
|
||||
|
||||
\`\`\`php
|
||||
$client = new \\Protocol\\ApiClient($token);
|
||||
|
||||
$client->contacts->update('WAz8eIbvDR60rouK', [
|
||||
'display_name' => 'UncleFrank',
|
||||
]);
|
||||
\`\`\`
|
||||
|
||||
</CodeGroup>
|
||||
<% operation.responseList.forEach(function(response){ %>
|
||||
<% if(response?.content && response?.content['application/json']){ %>
|
||||
<% if(response?.content['application/json'].schema.type === 'array'){ %>
|
||||
<CodeGroup title="Response">
|
||||
\`\`\`json {{ title: '200' }}
|
||||
<%- JSON.stringify(new Array(schemas.get(response?.content['application/json'].schema.items.$ref?.split('/').pop())?.examples), null, 2) %>
|
||||
\`\`\`
|
||||
</CodeGroup>
|
||||
<% } else { %>
|
||||
<CodeGroup title="Response">
|
||||
\`\`\`json {{ title: '200' }}
|
||||
<%- JSON.stringify(schemas.get(response?.content['application/json'].schema.$ref?.split('/').pop())?.examples, null, 2) %>
|
||||
\`\`\`
|
||||
</CodeGroup>
|
||||
<% }; -%>
|
||||
<% }; -%>
|
||||
<% }); -%>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
<% }); -%>
|
||||
`.trim()
|
||||
|
||||
export default template
|
||||
144
generator/templates/ApiTemplateBack.ts
Normal file
144
generator/templates/ApiTemplateBack.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
const template = `
|
||||
---
|
||||
id: usage
|
||||
slug: /usage
|
||||
title: Usage
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
<%- info.description %>
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
|
||||
<% sections.forEach(function(section){ %>
|
||||
|
||||
## <%- section.title %> [#<%= section.id %>]
|
||||
|
||||
<%- section.description %>
|
||||
|
||||
<% section.operations.forEach(function(operation){ %>
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
### <%- operation.summary %> [#<%- operation.operationId %>]
|
||||
|
||||
\`\`\`
|
||||
<%- operation.operation.toUpperCase() %> <%- operation.fullPath %>
|
||||
\`\`\`
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
<% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'path').length > 0){ %>
|
||||
#### Path Parameters
|
||||
|
||||
<ul className="method-list-group not-prose">
|
||||
<% operation.parameters
|
||||
.filter((parameter) => parameter.in === 'path').forEach(function(parameter){ %>
|
||||
<li className="method-list-item">
|
||||
<h4 className="method-list-item-label">
|
||||
<span className="method-list-item-label-name">
|
||||
<%- parameter.name %>
|
||||
</span>
|
||||
<span className="method-list-item-label-badge">
|
||||
<%- parameter.required ? 'required' : 'optional' %>
|
||||
</span>
|
||||
<span className="method-list-item-validation">
|
||||
<%- parameter.type %>
|
||||
</span>
|
||||
</h4>
|
||||
<% if(parameter.example){ %>
|
||||
<h4 className="method-list-item-label">
|
||||
Example:
|
||||
<span className="method-list-item-label-badge">
|
||||
<%- parameter.example %>
|
||||
</span>
|
||||
</h4>
|
||||
<% } %>
|
||||
<div class="method-list-item-description">
|
||||
<%- parameter.description %>
|
||||
</div>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% }; %>
|
||||
|
||||
<% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'header').length > 0){ %>
|
||||
#### Header Parameters
|
||||
<ul className="method-list-group not-prose">
|
||||
<% operation.parameters
|
||||
.filter((parameter) => parameter.in === 'header').forEach(function(parameter){ %>
|
||||
<li className="method-list-item">
|
||||
<h4 className="method-list-item-label">
|
||||
<span className="method-list-item-label-name">
|
||||
<%- parameter.name %>
|
||||
</span>
|
||||
<span className="method-list-item-label-badge">
|
||||
<%- parameter.required ? 'required' : 'optional' %>
|
||||
</span>
|
||||
<span className="method-list-item-validation">
|
||||
<%- parameter.type %>
|
||||
</span>
|
||||
</h4>
|
||||
<% if(parameter.example){ %>
|
||||
<h4 className="method-list-item-label">
|
||||
Example:
|
||||
<span className="method-list-item-label-badge">
|
||||
<%- parameter.example %>
|
||||
</span>
|
||||
</h4>
|
||||
<% } %>
|
||||
<div class="method-list-item-description">
|
||||
<%- parameter.description %>
|
||||
</div>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% }; %>
|
||||
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
<% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %>
|
||||
#### Body Parameters
|
||||
|
||||
\`\`\`json
|
||||
<%- JSON.stringify(operation.requestBody?.content['application/json'], null, 2) %>
|
||||
\`\`\`
|
||||
<% }; %>
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
#### Responses
|
||||
|
||||
<Tabs scrollable size="small" type="underlined" defaultActiveId="<%- operation.responseList[0].responseCode %>">
|
||||
<% operation.responseList.forEach(function(response){ %>
|
||||
<TabPanel id="<%- response.responseCode %>" label="<%- response.responseCode %>">
|
||||
|
||||
<%- response.description %>
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
<% if(response?.content && response?.content['application/json']){ %>
|
||||
\`\`\`json
|
||||
<%- JSON.stringify(response.content['application/json'], null, 2) %>
|
||||
\`\`\`
|
||||
<% }; %>
|
||||
|
||||
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
|
||||
|
||||
</TabPanel>
|
||||
<% }); %>
|
||||
</Tabs>
|
||||
|
||||
<br />
|
||||
<% }); %>
|
||||
<% }); %>
|
||||
|
||||
|
||||
`.trim()
|
||||
|
||||
export default template
|
||||
Reference in New Issue
Block a user