Skip to content

Commit

Permalink
🐛 Fix Open API spec / client generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontaylordev committed Nov 29, 2024
1 parent 51551c9 commit 605e28c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 293 deletions.
170 changes: 58 additions & 112 deletions src/Web/ClientApp-React/src/web-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@ export class TodoItemsClient {
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = PaginatedListOfTodoItemBriefDto.fromJS(resultData200);
return result200;
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = PaginatedListOfTodoItemBriefDto.fromJS(resultData200);
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<PaginatedListOfTodoItemBriefDto>(null as any);
}

/**
* @return OK
*/
createTodoItem(command: CreateTodoItemCommand): Promise<void> {
createTodoItem(command: CreateTodoItemCommand): Promise<number> {
let url_ = this.baseUrl + "/api/TodoItems";
url_ = url_.replace(/[?&]$/, "");

Expand All @@ -90,33 +87,26 @@ export class TodoItemsClient {
});
}

protected processCreateTodoItem(response: Response): Promise<void> {
protected processCreateTodoItem(response: Response): Promise<number> {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 201) {
if (status === 201) {
return response.text().then((_responseText) => {
let result201: any = null;
let resultData201 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
let result201: any = null;
let resultData201 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result201 = resultData201 !== undefined ? resultData201 : <any>null;

return throwException("A server side error occurred.", status, _responseText, _headers, result201);
return result201;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
return Promise.resolve<number>(null as any);
}

/**
* @return OK
*/
updateTodoItem(id: number, command: UpdateTodoItemCommand): Promise<void> {
let url_ = this.baseUrl + "/api/TodoItems/{id}";
if (id === undefined || id === null)
Expand All @@ -131,7 +121,6 @@ export class TodoItemsClient {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};

Expand All @@ -144,29 +133,22 @@ export class TodoItemsClient {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 204) {
if (status === 204) {
return response.text().then((_responseText) => {
return null;
return;
});
} else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("A server side error occurred.", status, _responseText, _headers);
return throwException("A server side error occurred.", status, _responseText, _headers);
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
}

/**
* @return OK
*/
deleteTodoItem(id: number): Promise<void> {
let url_ = this.baseUrl + "/api/TodoItems/{id}";
if (id === undefined || id === null)
Expand All @@ -177,7 +159,6 @@ export class TodoItemsClient {
let options_: RequestInit = {
method: "DELETE",
headers: {
"Accept": "application/json"
}
};

Expand All @@ -190,25 +171,18 @@ export class TodoItemsClient {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 204) {
if (status === 204) {
return response.text().then((_responseText) => {
return null;
return;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
}

/**
* @return OK
*/
updateTodoItemDetail(id: number, command: UpdateTodoItemDetailCommand): Promise<void> {
let url_ = this.baseUrl + "/api/TodoItems/UpdateDetail/{id}";
if (id === undefined || id === null)
Expand All @@ -223,7 +197,6 @@ export class TodoItemsClient {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};

Expand All @@ -236,21 +209,17 @@ export class TodoItemsClient {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 204) {
if (status === 204) {
return response.text().then((_responseText) => {
return null;
return;
});
} else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("A server side error occurred.", status, _responseText, _headers);
return throwException("A server side error occurred.", status, _responseText, _headers);
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
Expand Down Expand Up @@ -289,23 +258,20 @@ export class TodoListsClient {
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = TodosVm.fromJS(resultData200);
return result200;
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = TodosVm.fromJS(resultData200);
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<TodosVm>(null as any);
}

/**
* @return OK
*/
createTodoList(command: CreateTodoListCommand): Promise<void> {
createTodoList(command: CreateTodoListCommand): Promise<number> {
let url_ = this.baseUrl + "/api/TodoLists";
url_ = url_.replace(/[?&]$/, "");

Expand All @@ -325,33 +291,26 @@ export class TodoListsClient {
});
}

protected processCreateTodoList(response: Response): Promise<void> {
protected processCreateTodoList(response: Response): Promise<number> {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 201) {
if (status === 201) {
return response.text().then((_responseText) => {
let result201: any = null;
let resultData201 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
let result201: any = null;
let resultData201 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result201 = resultData201 !== undefined ? resultData201 : <any>null;

return throwException("A server side error occurred.", status, _responseText, _headers, result201);
return result201;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
return Promise.resolve<number>(null as any);
}

/**
* @return OK
*/
updateTodoList(id: number, command: UpdateTodoListCommand): Promise<void> {
let url_ = this.baseUrl + "/api/TodoLists/{id}";
if (id === undefined || id === null)
Expand All @@ -366,7 +325,6 @@ export class TodoListsClient {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};

Expand All @@ -379,29 +337,22 @@ export class TodoListsClient {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
if (status === 204) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 204) {
return response.text().then((_responseText) => {
return null;
return;
});
} else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("A server side error occurred.", status, _responseText, _headers);
return throwException("A server side error occurred.", status, _responseText, _headers);
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
}

/**
* @return OK
*/
deleteTodoList(id: number): Promise<void> {
let url_ = this.baseUrl + "/api/TodoLists/{id}";
if (id === undefined || id === null)
Expand All @@ -412,7 +363,6 @@ export class TodoListsClient {
let options_: RequestInit = {
method: "DELETE",
headers: {
"Accept": "application/json"
}
};

Expand All @@ -425,17 +375,13 @@ export class TodoListsClient {
followIfLoginRedirect(response);
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
if (status === 204) {
return response.text().then((_responseText) => {
return null;
});
} else if (status === 204) {
return response.text().then((_responseText) => {
return null;
return;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<void>(null as any);
Expand Down Expand Up @@ -474,21 +420,21 @@ export class WeatherForecastsClient {
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
if (Array.isArray(resultData200)) {
result200 = [] as any;
for (let item of resultData200)
result200!.push(WeatherForecast.fromJS(item));
}
else {
result200 = <any>null;
}
return result200;
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
if (Array.isArray(resultData200)) {
result200 = [] as any;
for (let item of resultData200)
result200!.push(WeatherForecast.fromJS(item));
}
else {
result200 = <any>null;
}
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<WeatherForecast[]>(null as any);
Expand Down
Loading

0 comments on commit 605e28c

Please sign in to comment.