Skip to content

Commit

Permalink
feat(api-client): API method parameter descriptions
Browse files Browse the repository at this point in the history
closes #29

Signed-off-by: Vojtech Masek <[email protected]>
  • Loading branch information
vmasek committed Jun 11, 2018
1 parent ce511c8 commit 320fabc
Show file tree
Hide file tree
Showing 8 changed files with 1,068 additions and 1,067 deletions.
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function transformParameters(
...param,
...determineParamType(paramRef ? paramRef.in : param.in),

description: replaceNewLines(param.description, ' '),
camelCaseName: camelCase(name),
importType: prefixImportedModels(typescriptType),
isArray,
Expand Down
2 changes: 1 addition & 1 deletion templates/ngx-service.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class APIClient {
{{#parameters.length}}
args: {
{{#parameters}}
{{&camelCaseName}}{{^isRequired}}?{{/isRequired}}: {{importType}}{{#isArray}}[]{{/isArray}},
{{&camelCaseName}}{{^isRequired}}?{{/isRequired}}: {{importType}}{{#isArray}}[]{{/isArray}},{{#description}} //{{^isRequired}} (optional){{/isRequired}} {{&.}}{{/description}}
{{/parameters}}
},
{{/parameters.length}}
Expand Down
4 changes: 2 additions & 2 deletions tests/custom/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class APIClient {
getItems(
args: {
pageSize: number,
page: number,
page: number, // page number
},
requestHttpOptions?: HttpOptions
): Observable<models.ItemList> {
Expand All @@ -63,7 +63,7 @@ export class APIClient {
getItemModels(
args: {
pageSize: number,
page: number,
page: number, // page number
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand Down
92 changes: 46 additions & 46 deletions tests/esquare/api/api-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class APIClient {

auth(
args: {
body: models.AuthForm,
body: models.AuthForm, // Structure entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -64,7 +64,7 @@ export class APIClient {

passwordRestoreRequest(
args: {
body: models.RestoreForm,
body: models.RestoreForm, // Structure entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -76,7 +76,7 @@ export class APIClient {

passwordRestoreEmailRequest(
args: {
body: models.RestoreRequestForm,
body: models.RestoreRequestForm, // Structure entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -88,7 +88,7 @@ export class APIClient {

passwordRestoreCheckRestoreGuid(
args: {
restoreGuid: string,
restoreGuid: string, // RestoreGuid for check
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand Down Expand Up @@ -118,7 +118,7 @@ export class APIClient {

addStructureEntity(
args: {
body: models.StructureAddParameters,
body: models.StructureAddParameters, // Structure entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<models.Structure> {
Expand All @@ -130,8 +130,8 @@ export class APIClient {

updateStructureEntity(
args: {
structureId: number,
body: models.StructureForm,
structureId: number, // structure id to update
body: models.StructureForm, // Structure entity object that needs to be updated
},
requestHttpOptions?: HttpOptions
): Observable<models.Structure> {
Expand All @@ -143,7 +143,7 @@ export class APIClient {

deleteStructureEntity(
args: {
structureId: number,
structureId: number, // structure id to delete
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -161,8 +161,8 @@ export class APIClient {
args: {
status?: models.Status,
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // id | title | subtitle | criticality | status | issues | deadline
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down Expand Up @@ -194,7 +194,7 @@ export class APIClient {
*/
getReportDetails(
args: {
id: number,
id: number, // report id to get
},
requestHttpOptions?: HttpOptions
): Observable<models.ReportItem[]> {
Expand All @@ -210,10 +210,10 @@ export class APIClient {
*/
getReportPreview(
args: {
templateId: number,
templateId: number, // [See #/definitions/ReportTemplate](#/Data_Import/getReportDetails)
pageSize: number,
page: number,
orderBy?: number,
page: number, // page number
orderBy?: number, // (optional) column id
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down Expand Up @@ -242,7 +242,7 @@ export class APIClient {
*/
getImportHistory(
args: {
templateId: number,
templateId: number, // [See #/definitions/ReportTemplate](#/Data_Import/getReportDetails)
},
requestHttpOptions?: HttpOptions
): Observable<models.ImportHistoryItem[]> {
Expand All @@ -258,8 +258,8 @@ export class APIClient {
*/
uploadFile(
args: {
templateId: number,
file: File,
templateId: number, // [See #/definitions/ReportTemplate](#/Data_Import/getReportDetails)
file: File, // file to upload
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -275,7 +275,7 @@ export class APIClient {
*/
listTemplateColumns(
args: {
templateId: number,
templateId: number, // [See #/definitions/ReportTemplate](#/Data_Import/getReportDetails)
},
requestHttpOptions?: HttpOptions
): Observable<models.Column[]> {
Expand All @@ -291,7 +291,7 @@ export class APIClient {
*/
listReportColumns(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<models.Column[]> {
Expand All @@ -307,8 +307,8 @@ export class APIClient {
*/
saveColumnsMapping(
args: {
id: number,
body: any,
id: number, // Id of current import
body: any, // Column mappint for current import
},
requestHttpOptions?: HttpOptions
): Observable<models.Table> {
Expand All @@ -324,7 +324,7 @@ export class APIClient {
*/
getValidationTable(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<models.ValidatedTable> {
Expand All @@ -340,8 +340,8 @@ export class APIClient {
*/
downloadImportedFile(
args: {
id: number,
all?: boolean,
id: number, // Id of current import
all?: boolean, // (optional) Indicator of downloading data(all or errors only)
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -360,7 +360,7 @@ export class APIClient {
*/
importConfirmation(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<models.ImportResponse> {
Expand All @@ -376,7 +376,7 @@ export class APIClient {
*/
downloadImportOriginalFile(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -392,7 +392,7 @@ export class APIClient {
*/
downloadImportSkippedFile(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -408,7 +408,7 @@ export class APIClient {
*/
cancelImport(
args: {
id: number,
id: number, // Id of current import
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand All @@ -424,9 +424,9 @@ export class APIClient {
*/
overrideImport(
args: {
id: number,
description: string,
file: File,
id: number, // Id of current import
description: string, // description of override request
file: File, // file to upload
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand Down Expand Up @@ -464,8 +464,8 @@ export class APIClient {
period?: models.Period,
status?: models.IssueStatus,
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // name | school | dueDate | alert
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down Expand Up @@ -503,8 +503,8 @@ export class APIClient {
period?: models.Period,
status?: models.ImportStatus,
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // name | issues | dueDate | progress
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down Expand Up @@ -538,11 +538,11 @@ export class APIClient {
period?: models.Period,
status?: models.ImportStatus,
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // name | issues | dueDate | progress
order?: models.Order,
assignedToRole?: number,
unassignedFromRole?: number,
assignedToRole?: number, // (optional) role id | [Screenshot from design](http://prntscr.com/ib9yal)
unassignedFromRole?: number, // (optional) role id | [Screenshot from design](http://prntscr.com/ib9z16)
},
requestHttpOptions?: HttpOptions
): Observable<any> {
Expand Down Expand Up @@ -578,7 +578,7 @@ export class APIClient {

createUser(
args: {
body: models.UserDetails,
body: models.UserDetails, // User entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<models.UserDetails> {
Expand Down Expand Up @@ -612,7 +612,7 @@ export class APIClient {
updateUser(
args: {
id: number,
body: models.UserDetails,
body: models.UserDetails, // User entity object that needs to be updated
},
requestHttpOptions?: HttpOptions
): Observable<models.UserDetails> {
Expand Down Expand Up @@ -649,7 +649,7 @@ export class APIClient {

createRole(
args: {
body: any,
body: any, // Role entity object that needs to be added
},
requestHttpOptions?: HttpOptions
): Observable<models.RoleDetailsItem> {
Expand Down Expand Up @@ -741,8 +741,8 @@ export class APIClient {
getNotificationsList(
args: {
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // name | description | priority | date
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down Expand Up @@ -800,8 +800,8 @@ export class APIClient {
args: {
moduleId: number,
pageSize: number,
page: number,
orderBy: string,
page: number, // page number
orderBy: string, // name | description | priority | date
order?: models.Order,
},
requestHttpOptions?: HttpOptions
Expand Down
2 changes: 1 addition & 1 deletion tests/esquare/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ paths:
parameters:
- name: id
in: path
description: Id of current import
description: Id of current import # todo: this is generated as two body (with file) params and not as multipart form
required: true
type: integer
format: int64
Expand Down
Loading

0 comments on commit 320fabc

Please sign in to comment.