-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add API/Model Docs to typescript-fetch codegen #18351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mason-at-pieces
wants to merge
22
commits into
OpenAPITools:master
Choose a base branch
from
mason-at-pieces:typescript-fetch-docs-generator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3a95f51
feat: Add model and doc templates to TS Fetch codegen
mason-at-pieces c6eb891
feat(typescript-fetch): add API and model documentation templates
mason-at-pieces 37f99a7
chore: ran tests
mason-at-pieces 1219069
build(Dockerfile): Remove JAVA_OPTS environment setting
mason-at-pieces 3cc70b2
docs: Correct markdown link case sensitivity
mason-at-pieces ed89f28
feat: added /docs directory
mason-at-pieces dba6aca
chore: ran checks
mason-at-pieces da1ea50
fix: Normalize path separators in TypeScriptFetchCodeGen
mason-at-pieces 55d8286
refactor(TypeScriptFetchClientCodegen): Adjust model template handling
mason-at-pieces 5356323
chore: updated codegen and removed root level markdown fiels
mason-at-pieces 62e389e
feat: Add model and doc templates to TS Fetch codegen
mason-at-pieces 30b449a
feat(typescript-fetch): add API and model documentation templates
mason-at-pieces 53f20c2
chore: ran tests
mason-at-pieces bb5cffc
build(Dockerfile): Remove JAVA_OPTS environment setting
mason-at-pieces fcd144a
docs: Correct markdown link case sensitivity
mason-at-pieces a720bb7
feat: added /docs directory
mason-at-pieces 0165de1
chore: ran checks
mason-at-pieces 1472043
fix: Normalize path separators in TypeScriptFetchCodeGen
mason-at-pieces 5d5710a
refactor(TypeScriptFetchClientCodegen): Adjust model template handling
mason-at-pieces c504ccd
chore: updated codegen and removed root level markdown fiels
mason-at-pieces 1979351
Merge remote-tracking branch 'origin/typescript-fetch-docs-generator'…
mason-at-pieces 22d04c8
chore: updated tests
mason-at-pieces File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
82 changes: 82 additions & 0 deletions
82
modules/openapi-generator/src/main/resources/typescript-fetch/api_doc.mustache
This file contains hidden or 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,82 @@ | ||
# {{moduleName}}.{{classname}}{{#description}} | ||
|
||
{{description}}{{/description}} | ||
|
||
All URIs are relative to *{{basePath}}* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{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 { {{classname}} } from '{{{projectName}}}'; | ||
|
||
const apiInstance = new {{{moduleName}}}.{{classname}}(); | ||
|
||
{{#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}} | {{/-last}}{{#-last}}>**{{/-last}}{{/enumVars}}{{/allowableValues}}{{/isEnum}} | {{description}} |{{^required}} (optional){{/required}} defaults to {{{.}}} | ||
{{/defaultValue}}{{/allParams}} | ||
|
||
### Return type | ||
|
||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/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}} | ||
|
37 changes: 37 additions & 0 deletions
37
modules/openapi-generator/src/main/resources/typescript-fetch/model_doc.mustache
This file contains hidden or 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,37 @@ | ||
{{#models}}{{#model}} | ||
# {{classname}} | ||
|
||
{{#description}}{{&description}} | ||
{{/description}} | ||
|
||
## Properties | ||
|
||
Name | Type | ||
------------ | ------------- | ||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | ||
{{/vars}} | ||
|
||
## Example | ||
|
||
```typescript | ||
import { {{classname}} } from '{{npmName}}' | ||
|
||
// TODO: Update the object below with actual values | ||
const example: {{classname}} = { | ||
{{#vars}} | ||
"{{name}}": {{{example}}}, | ||
{{/vars}} | ||
} | ||
|
||
console.log(example) | ||
|
||
// Convert the instance to a JSON string | ||
const exampleJSON: string = JSON.stringify(example) | ||
console.log(exampleJSON) | ||
|
||
// Parse the JSON string back to an object | ||
const exampleParsed = JSON.parse(exampleJSON) as {{classname}} | ||
console.log(exampleParsed) | ||
``` | ||
|
||
{{/model}}{{/models}} |
3 changes: 3 additions & 0 deletions
3
samples/client/petstore/typescript-fetch/builds/allOf-nullable/.openapi-generator/FILES
This file contains hidden or 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,3 +1,6 @@ | ||
Club.md | ||
DefaultApi.md | ||
Owner.md | ||
apis/DefaultApi.ts | ||
apis/index.ts | ||
index.ts | ||
|
32 changes: 32 additions & 0 deletions
32
samples/client/petstore/typescript-fetch/builds/allOf-nullable/Club.md
This file contains hidden or 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,32 @@ | ||
|
||
# Club | ||
|
||
|
||
## Properties | ||
|
||
Name | Type | ||
------------ | ------------- | ||
**owner** | [**Owner**](Owner.md) | ||
|
||
## Example | ||
|
||
```typescript | ||
import { Club } from '' | ||
|
||
// TODO: Update the object below with actual values | ||
const example: Club = { | ||
"owner": null, | ||
} | ||
|
||
console.log(example) | ||
|
||
// Convert the instance to a JSON string | ||
const exampleJSON: string = JSON.stringify(example) | ||
console.log(exampleJSON) | ||
|
||
// Parse the JSON string back to an object | ||
const exampleParsed = JSON.parse(exampleJSON) as Club | ||
console.log(exampleParsed) | ||
``` | ||
|
||
|
||
mason-at-pieces marked this conversation as resolved.
Show resolved
Hide resolved
|
61 changes: 61 additions & 0 deletions
61
samples/client/petstore/typescript-fetch/builds/allOf-nullable/DefaultApi.md
This file contains hidden or 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,61 @@ | ||
# .DefaultApi | ||
|
||
All URIs are relative to *http://api.example.xyz/v1* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**list**](DefaultApi.md#list) | **GET** /person/display/{personId} | | ||
|
||
|
||
## **list** | ||
> Club list() | ||
|
||
|
||
### Example | ||
|
||
|
||
```typescript | ||
import { DefaultApi } from ''; | ||
|
||
const apiInstance = new .DefaultApi(); | ||
|
||
let body:.DefaultApiListRequest = { | ||
// string | The id of the person to retrieve | ||
personId: personId_example, | ||
}; | ||
|
||
apiInstance.list(body).then((data:any) => { | ||
console.log('API called successfully. Returned data: ' + data); | ||
}).catch((error:any) => console.error(error)); | ||
``` | ||
|
||
|
||
### Parameters | ||
|
||
Name | Type | Description | Notes | ||
------------- | ------------- | ------------- | ------------- | ||
**personId** | [**string**] | The id of the person to retrieve | defaults to undefined | ||
|
||
|
||
### Return type | ||
|
||
[**Club**](Club.md) | ||
|
||
### Authorization | ||
|
||
No authorization required | ||
|
||
### HTTP request headers | ||
|
||
- **Content-Type**: Not defined | ||
- **Accept**: application/json | ||
|
||
|
||
### HTTP response details | ||
| Status code | Description | Response headers | | ||
|-------------|-------------|------------------| | ||
**200** | OK | - | | ||
|
||
[[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) | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
samples/client/petstore/typescript-fetch/builds/allOf-nullable/Owner.md
This file contains hidden or 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,32 @@ | ||
|
||
# Owner | ||
|
||
|
||
## Properties | ||
|
||
Name | Type | ||
------------ | ------------- | ||
**name** | **string** | ||
|
||
## Example | ||
|
||
```typescript | ||
import { Owner } from '' | ||
|
||
// TODO: Update the object below with actual values | ||
const example: Owner = { | ||
"name": null, | ||
} | ||
|
||
console.log(example) | ||
|
||
// Convert the instance to a JSON string | ||
const exampleJSON: string = JSON.stringify(example) | ||
console.log(exampleJSON) | ||
|
||
// Parse the JSON string back to an object | ||
const exampleParsed = JSON.parse(exampleJSON) as Owner | ||
console.log(exampleParsed) | ||
``` | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
samples/client/petstore/typescript-fetch/builds/allOf-readonly/.openapi-generator/FILES
This file contains hidden or 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,3 +1,6 @@ | ||
Club.md | ||
DefaultApi.md | ||
Owner.md | ||
apis/DefaultApi.ts | ||
apis/index.ts | ||
index.ts | ||
|
32 changes: 32 additions & 0 deletions
32
samples/client/petstore/typescript-fetch/builds/allOf-readonly/Club.md
This file contains hidden or 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,32 @@ | ||
|
||
# Club | ||
|
||
|
||
## Properties | ||
|
||
Name | Type | ||
------------ | ------------- | ||
**owner** | [**Owner**](Owner.md) | ||
|
||
## Example | ||
|
||
```typescript | ||
import { Club } from '' | ||
|
||
// TODO: Update the object below with actual values | ||
const example: Club = { | ||
"owner": null, | ||
} | ||
|
||
console.log(example) | ||
|
||
// Convert the instance to a JSON string | ||
const exampleJSON: string = JSON.stringify(example) | ||
console.log(exampleJSON) | ||
|
||
// Parse the JSON string back to an object | ||
const exampleParsed = JSON.parse(exampleJSON) as Club | ||
console.log(exampleParsed) | ||
``` | ||
|
||
|
61 changes: 61 additions & 0 deletions
61
samples/client/petstore/typescript-fetch/builds/allOf-readonly/DefaultApi.md
This file contains hidden or 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,61 @@ | ||
# .DefaultApi | ||
|
||
All URIs are relative to *http://api.example.xyz/v1* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**list**](DefaultApi.md#list) | **GET** /person/display/{personId} | | ||
|
||
|
||
## **list** | ||
> Club list() | ||
|
||
|
||
### Example | ||
|
||
|
||
```typescript | ||
import { DefaultApi } from ''; | ||
|
||
const apiInstance = new .DefaultApi(); | ||
|
||
let body:.DefaultApiListRequest = { | ||
// string | The id of the person to retrieve | ||
personId: personId_example, | ||
}; | ||
|
||
apiInstance.list(body).then((data:any) => { | ||
console.log('API called successfully. Returned data: ' + data); | ||
}).catch((error:any) => console.error(error)); | ||
``` | ||
|
||
|
||
### Parameters | ||
|
||
Name | Type | Description | Notes | ||
------------- | ------------- | ------------- | ------------- | ||
**personId** | [**string**] | The id of the person to retrieve | defaults to undefined | ||
|
||
|
||
### Return type | ||
|
||
[**Club**](Club.md) | ||
|
||
### Authorization | ||
|
||
No authorization required | ||
|
||
### HTTP request headers | ||
|
||
- **Content-Type**: Not defined | ||
- **Accept**: application/json | ||
|
||
|
||
### HTTP response details | ||
| Status code | Description | Response headers | | ||
|-------------|-------------|------------------| | ||
**200** | OK | - | | ||
|
||
[[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) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.