Skip to content

Commit

Permalink
[typescript] Generate documentation and examples (#9413)
Browse files Browse the repository at this point in the history
* generate docs for typescript

* commit changed files
  • Loading branch information
NouemanKHAL committed Jun 12, 2021
1 parent 98ae4ab commit 624b6a7
Show file tree
Hide file tree
Showing 27 changed files with 6,877 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/configs/typescript-consolidated-deno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
additionalProperties:
platform: deno
npmName: ts-petstore-client
projectName: ts-petstore-client
moduleName: petstore
2 changes: 2 additions & 0 deletions bin/configs/typescript-consolidated-inversify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ additionalProperties:
platform: node
npmName: ts-petstore-client
useInversify: true
projectName: ts-petstore-client
moduleName: petstore
2 changes: 2 additions & 0 deletions bin/configs/typescript-consolidated-jquery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
additionalProperties:
framework: jquery
npmName: ts-petstore-client
projectName: ts-petstore-client
moduleName: petstore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ additionalProperties:
platform: node
npmName: ts-petstore-client
useObjectParameters: true
projectName: ts-petstore-client
moduleName: petstore
2 changes: 2 additions & 0 deletions bin/configs/typescript-consolidated-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
additionalProperties:
platform: node
npmName: ts-petstore-client
projectName: ts-petstore-client
moduleName: petstore

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# {{moduleName}}.{{classname}}{{#description}}

{{description}}{{/description}}

All URIs are relative to *{{basePath}}*

Method | HTTP request | Description
------------- | ------------- | -------------
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}

{{#operations}}
{{#operation}}
# **{{{operationId}}}**
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}})

{{#notes}}
{{{notes}}}
{{/notes}}

### Example


```typescript
import { {{{moduleName}}} } from '{{{projectName}}}';
import * as fs from 'fs';

const configuration = {{{moduleName}}}.createConfiguration();
const apiInstance = new {{{moduleName}}}.{{classname}}(configuration);

{{#hasParams}}
let body:{{{moduleName}}}.{{classname}}{{operationIdCamelCase}}Request = {
{{#allParams}}
// {{{dataType}}}{{#description}} | {{{description}}}{{/description}}{{^required}} (optional){{/required}}
{{paramName}}: {{{example}}},
{{/allParams}}
};
{{/hasParams}}
{{^hasParams}}
let body:any = {};
{{/hasParams}}

apiInstance.{{{operationId}}}(body).then((data:any) => {
console.log('API called successfully. Returned data: ' + data);
}).catch((error:any) => console.error(error));
```


### Parameters
{{^hasParams}}This endpoint does not need any parameter.{{/hasParams}}{{#allParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
{{#allParams}}{{^defaultValue}} **{{paramName}}** | {{^isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}| {{description}} |
{{/defaultValue}}{{/allParams}}{{#allParams}}{{#defaultValue}} **{{paramName}}** | {{^isPrimitiveType}}{{^isEnum}}**{{dataType}}**{{/isEnum}}{{/isPrimitiveType}}{{#isPrimitiveType}}[**{{dataType}}**]{{/isPrimitiveType}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}{{#-first}}**Array<{{/-first}}{{value}}{{^-last}} &#124; {{/-last}}{{#-last}}>**{{/-last}}{{/enumVars}}{{/allowableValues}}{{/isEnum}} | {{description}} |{{^required}} (optional){{/required}} defaults to {{{.}}}
{{/defaultValue}}{{/allParams}}

### Return type

{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}

### Authorization

{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}

### HTTP request headers

- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}

{{#responses.0}}

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
{{#responses}}
**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
{{/responses}}
{{/responses.0}}

[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)

{{/operation}}
{{/operations}}

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.gitignore
PetApi.md
README.md
StoreApi.md
UserApi.md
apis/PetApi.ts
apis/StoreApi.ts
apis/UserApi.ts
Expand Down
Loading

0 comments on commit 624b6a7

Please sign in to comment.