mirror of
https://github.com/coder/coder.git
synced 2026-11-26 07:46:04 +08:00
* WIP * Gen * WIP * chi swagger * WIP * WIP * WIP * GetWorkspaces * GetWorkspaces * Markdown * Use widdershins * WIP * WIP * WIP * Markdown template * Fix: makefile * fmt * Fix: comment * Enable swagger conditionally * fix: site * Default false * Flag tests * fix * fix * template fixes * Fix * Fix * Fix * WIP * Formatted * Cleanup * Templates * BEGIN END SECTION * subshell exit code * Fix * Fix merge * WIP * Fix * Fix fmt * Fix * Generic api.md page * Fix merge * Link pages * Fix * Fix * Fix: links * Add icon * Write manifest file * Fix fmt * Fix: enterprise * Fix: Swagger.Enable * Fix: rename apidocs to apidoc * Fix: find -not -prune * Fix: json not available * Fix: rename Coderd API to Coder API * Fix: npm exec * Fix: api dir * Fix: by ID * Fix: string uuid * Fix: include deleted * Fix: indirect go.mod * Fix: source lib.sh * Fix: shellcheck * Fix: pushd popd * Fix: fmt * Fix: improve workspaces * Fix: swagger-enable * Fix * Fix: mention only HTTP 200 * Fix: IDs * Fix: https * Fix: icon * More APis * Fix: format swagger.json * Fix: SwaggerEndpoint * Fix: SCRIPT_DIR * Fix: PROJECT_ROOT * Fix: use code tags in schemas.md * Fix: examples * Fix: examples * Fix: improve format * Fix: date-time,enums * Fix: include_deleted * Fix: array of * Fix: parameter, response * Fix: string time or null * Workspaces: more docs * Workspaces: more docs * Fix: renderDisplayName * Fix: ActiveUserCount * Fix * Fix: typo * Templates: docs * Notice: incomplete
158 lines
3.9 KiB
Plaintext
158 lines
3.9 KiB
Plaintext
{{
|
|
function renderSinglePropertyType(p) {
|
|
if (!p.$ref) {
|
|
return p.type;
|
|
}
|
|
|
|
const pRef = p.$ref.replace("#/components/schemas/","");
|
|
if (pRef == "codersdk.NullTime") {
|
|
return "string(time) or `null`";
|
|
}
|
|
return "[" + pRef + "](#" + pRef.replace(".","").toLowerCase() + ")";
|
|
}
|
|
|
|
function renderPropertyType(p) {
|
|
if (p.type == "array") {
|
|
return "array of " + renderSinglePropertyType(p.schema.items);
|
|
}
|
|
return renderSinglePropertyType(p);
|
|
}
|
|
|
|
function renderDisplayName(p) {
|
|
if (p.displayName == "» **additionalProperties**") {
|
|
return "» `[any property]`";
|
|
}
|
|
if (p.displayName == "**additionalProperties**") {
|
|
return "`[any property]`";
|
|
}
|
|
return "`" + p.displayName + "`";
|
|
}
|
|
|
|
function renderDescription(p) {
|
|
if (!p.description) {
|
|
return "none";
|
|
}
|
|
|
|
const toSnakeCase = str =>
|
|
str
|
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
|
.map(x => x.toLowerCase())
|
|
.join('_');
|
|
|
|
const words = p.description.split(' ');
|
|
if (words.length == 0) {
|
|
return "none";
|
|
}
|
|
|
|
const countUppercase = words[0].length - words[0].replace(/[A-Z]/g, '').length;
|
|
if (countUppercase > 1) {
|
|
const displayName = p.displayName.charAt(0).toUpperCase() + p.displayName.replaceAll("_", " ").toLowerCase().slice(1);
|
|
return displayName + " " + words.slice(1).join(' ');
|
|
}
|
|
return p.description;
|
|
}
|
|
}}
|
|
|
|
{{? data.api.components && data.api.components.securitySchemes }}{{#def.security}}{{?}}
|
|
|
|
{{ for (var r in data.resources) { }}
|
|
{{ data.resource = data.resources[r]; }}
|
|
|
|
<!-- APIDOCGEN: BEGIN SECTION -->
|
|
{{= data.tags.section }}# {{= r}}
|
|
|
|
> This page is incomplete, stay tuned.
|
|
|
|
{{? data.resource.description }}{{= data.resource.description}}{{?}}
|
|
|
|
{{ for (var m in data.resource.methods) { }}
|
|
{{ data.operationUniqueName = m; }}
|
|
{{ data.method = data.resource.methods[m]; }}
|
|
{{ data.operationUniqueSlug = data.method.slug; }}
|
|
{{ data.operation = data.method.operation; }}
|
|
{{= data.templates.operation(data) }}
|
|
{{ } /* of methods */ }}
|
|
|
|
{{= data.tags.endSection }}
|
|
{{ } /* of resources */ }}
|
|
|
|
{{? data.api.components && data.api.components.schemas }}
|
|
{{= data.tags.section }}
|
|
|
|
<!-- APIDOCGEN: BEGIN SECTION -->
|
|
# Schemas
|
|
|
|
> This page is incomplete, stay tuned.
|
|
|
|
{{ for (var s in data.components.schemas) {
|
|
if (s == "codersdk.NullTime") {
|
|
continue;
|
|
}
|
|
}}
|
|
{{ var origSchema = data.components.schemas[s]; }}
|
|
{{ var schema = data.api.components.schemas[s]; }}
|
|
|
|
{{= data.tags.section }}
|
|
## {{=s}}
|
|
|
|
{{? data.options.yaml }}
|
|
```yaml
|
|
{{=data.utils.yaml.stringify(data.utils.getSample(schema,data.options,{quiet:true},data.api))}}
|
|
{{??}}
|
|
```json
|
|
{{=data.utils.safejson(data.utils.getSample(schema,data.options,{quiet:true},data.api),null,2)}}
|
|
{{?}}```
|
|
|
|
{{ var enums = []; }}
|
|
{{ var blocks = data.utils.schemaToArray(origSchema,-1,{trim:true,join:true},data); }}
|
|
{{ for (var block of blocks) {
|
|
for (var p of block.rows) {
|
|
if (p.schema && p.schema.enum) {
|
|
for (var e of p.schema.enum) {
|
|
enums.push({name:p.name,value:e});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}}
|
|
|
|
{{~ blocks :block}}
|
|
{{? block.title }}{{= block.title}}{{= '\n\n'}}{{?}}
|
|
{{? block.externalDocs}}
|
|
<a href="{{=block.externalDocs.url}}">{{=block.externalDocs.description||'External documentation'}}</a>
|
|
{{?}}
|
|
|
|
{{? block===blocks[0] }}
|
|
{{= data.tags.section }}
|
|
|
|
### Properties
|
|
{{?}}
|
|
|
|
{{? block.rows.length}}|Name|Type|Required|Restrictions|Description|
|
|
|---|---|---|---|---|{{?}}
|
|
{{~ block.rows :p}}|{{= renderDisplayName(p)}}|{{= renderPropertyType(p)}}|{{=p.required}}|{{=p.restrictions||'none'}}|{{= renderDescription(p)}}|
|
|
{{~}}
|
|
{{~}}
|
|
{{? (blocks[0].rows.length === 0) && (blocks.length === 1) }}
|
|
*None*
|
|
{{?}}
|
|
|
|
{{? enums.length > 0 }}
|
|
{{= data.tags.section }}
|
|
|
|
#### Enumerated Values
|
|
|
|
|Property|Value|
|
|
|---|---|
|
|
{{~ enums :e}}|{{=e.name}}|{{=data.utils.toPrimitive(e.value)}}|
|
|
{{~}}
|
|
|
|
{{= data.tags.endSection }}
|
|
{{?}}
|
|
|
|
{{= data.tags.endSection }}
|
|
{{= data.tags.endSection }}
|
|
{{ } /* of schemas */ }}
|
|
|
|
{{?}}
|