Skip to content

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
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Apr 10, 2024
c6eb891
feat(typescript-fetch): add API and model documentation templates
mason-at-pieces Apr 10, 2024
37f99a7
chore: ran tests
mason-at-pieces Apr 10, 2024
1219069
build(Dockerfile): Remove JAVA_OPTS environment setting
mason-at-pieces Apr 11, 2024
3cc70b2
docs: Correct markdown link case sensitivity
mason-at-pieces Apr 11, 2024
ed89f28
feat: added /docs directory
mason-at-pieces Apr 12, 2024
dba6aca
chore: ran checks
mason-at-pieces Apr 12, 2024
da1ea50
fix: Normalize path separators in TypeScriptFetchCodeGen
mason-at-pieces Apr 13, 2024
55d8286
refactor(TypeScriptFetchClientCodegen): Adjust model template handling
mason-at-pieces Apr 18, 2024
5356323
chore: updated codegen and removed root level markdown fiels
mason-at-pieces Apr 18, 2024
62e389e
feat: Add model and doc templates to TS Fetch codegen
mason-at-pieces Apr 10, 2024
30b449a
feat(typescript-fetch): add API and model documentation templates
mason-at-pieces Apr 10, 2024
53f20c2
chore: ran tests
mason-at-pieces Apr 10, 2024
bb5cffc
build(Dockerfile): Remove JAVA_OPTS environment setting
mason-at-pieces Apr 11, 2024
fcd144a
docs: Correct markdown link case sensitivity
mason-at-pieces Apr 11, 2024
a720bb7
feat: added /docs directory
mason-at-pieces Apr 12, 2024
0165de1
chore: ran checks
mason-at-pieces Apr 12, 2024
1472043
fix: Normalize path separators in TypeScriptFetchCodeGen
mason-at-pieces Apr 13, 2024
5d5710a
refactor(TypeScriptFetchClientCodegen): Adjust model template handling
mason-at-pieces Apr 18, 2024
c504ccd
chore: updated codegen and removed root level markdown fiels
mason-at-pieces Apr 18, 2024
1979351
Merge remote-tracking branch 'origin/typescript-fetch-docs-generator'…
mason-at-pieces May 1, 2024
22d04c8
chore: updated tests
mason-at-pieces May 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM maven:3-eclipse-temurin-17
ENV GEN_DIR /opt/openapi-generator
WORKDIR ${GEN_DIR}
VOLUME ${MAVEN_HOME}/.m2/repository
ENV JAVA_OPTS="-Xms2g -Xmx20g"

# Required from a licensing standpoint
COPY ./LICENSE ${GEN_DIR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public TypeScriptFetchClientCodegen() {
embeddedTemplateDir = templateDir = "typescript-fetch";

this.apiTemplateFiles.put("apis.mustache", ".ts");
this.modelTemplateFiles.put("models.mustache", ".ts");

this.modelDocTemplateFiles.put("model_doc.mustache", ".md");
this.apiDocTemplateFiles.put("api_doc.mustache", ".md");

this.addExtraReservedWords();

Expand Down Expand Up @@ -251,7 +255,6 @@ public void processOpts() {
}

if (!withoutRuntimeChecks) {
this.modelTemplateFiles.put("models.mustache", ".ts");
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
}
Expand Down
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}} &#124; {{/-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}}

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}}
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
Expand Down
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)
```


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)


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)
```


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
Expand Down
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)
```


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)


Loading