Skip to content

Commit

Permalink
chore: generate api
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswinger committed Sep 4, 2024
1 parent f148d85 commit 855ed66
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ repos:
- id: check-toml
- id: check-yaml
- id: trailing-whitespace
exclude: ^.*\.(lock)$
exclude: ^web/src/api/generated/|^.*\.(lock)$
- id: end-of-file-fixer
exclude: ^.*\.(lock)$
exclude: ^web/src/api/generated/|^.*\.(lock)$
- id: mixed-line-ending
exclude: ^.*\.(lock)$
- id: detect-private-key
Expand Down
2 changes: 2 additions & 0 deletions web/generate-api-typescript-client-pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -eo

PATTERN="api/src/features/*"
PATTERN+="|api/src/entities/*"
PATTERN+="|api/src/common/*"
PATTERN+="|api/src/authentication/*"

CHANGED_API_FILES=()
while read; do
Expand Down
16 changes: 10 additions & 6 deletions web/src/api/generated/core/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
Expand Down Expand Up @@ -145,10 +145,13 @@ export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Reso
};

export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise<Record<string, string>> => {
const token = await resolve(options, config.TOKEN);
const username = await resolve(options, config.USERNAME);
const password = await resolve(options, config.PASSWORD);
const additionalHeaders = await resolve(options, config.HEADERS);
const [token, username, password, additionalHeaders] = await Promise.all([
resolve(options, config.TOKEN),
resolve(options, config.USERNAME),
resolve(options, config.PASSWORD),
resolve(options, config.HEADERS),
]);

const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {}

const headers = Object.entries({
Expand All @@ -172,7 +175,7 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio
headers['Authorization'] = `Basic ${credentials}`;
}

if (options.body) {
if (options.body !== undefined) {
if (options.mediaType) {
headers['Content-Type'] = options.mediaType;
} else if (isBlob(options.body)) {
Expand Down Expand Up @@ -212,6 +215,7 @@ export const sendRequest = async <T>(
data: body ?? formData,
method: options.method,
withCredentials: config.WITH_CREDENTIALS,
withXSRFToken: config.CREDENTIALS === 'include' ? config.WITH_CREDENTIALS : false,
cancelToken: source.token,
};

Expand Down
1 change: 1 addition & 0 deletions web/src/api/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type { AddTodoRequest } from './models/AddTodoRequest';
export type { AddTodoResponse } from './models/AddTodoResponse';
export type { DeleteTodoByIdResponse } from './models/DeleteTodoByIdResponse';
export type { ErrorResponse } from './models/ErrorResponse';
export type { GetTodoAllResponse } from './models/GetTodoAllResponse';
export type { GetTodoByIdResponse } from './models/GetTodoByIdResponse';
export type { UpdateTodoRequest } from './models/UpdateTodoRequest';
export type { UpdateTodoResponse } from './models/UpdateTodoResponse';
Expand Down
1 change: 1 addition & 0 deletions web/src/api/generated/models/AddTodoRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
export type AddTodoRequest = {
title: string;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/AddTodoResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export type AddTodoResponse = {
title: string;
is_completed: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/DeleteTodoByIdResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
export type DeleteTodoByIdResponse = {
success: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/ErrorResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export type ErrorResponse = {
debug?: string;
extra?: (Record<string, any> | null);
};

11 changes: 11 additions & 0 deletions web/src/api/generated/models/GetTodoAllResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type GetTodoAllResponse = {
id: string;
title: string;
is_completed: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/GetTodoByIdResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export type GetTodoByIdResponse = {
title: string;
is_completed: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/UpdateTodoRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export type UpdateTodoRequest = {
title?: string;
is_completed: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/UpdateTodoResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
export type UpdateTodoResponse = {
success: boolean;
};

1 change: 1 addition & 0 deletions web/src/api/generated/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export type User = {
roles: Array<string>;
scope: AccessLevel;
};

5 changes: 3 additions & 2 deletions web/src/api/generated/services/TodosService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type { AddTodoRequest } from '../models/AddTodoRequest';
import type { AddTodoResponse } from '../models/AddTodoResponse';
import type { DeleteTodoByIdResponse } from '../models/DeleteTodoByIdResponse';
import type { GetTodoAllResponse } from '../models/GetTodoAllResponse';
import type { GetTodoByIdResponse } from '../models/GetTodoByIdResponse';
import type { UpdateTodoRequest } from '../models/UpdateTodoRequest';
import type { UpdateTodoResponse } from '../models/UpdateTodoResponse';
Expand All @@ -17,10 +18,10 @@ export class TodosService {

/**
* Get Todo All
* @returns any Successful Response
* @returns GetTodoAllResponse Successful Response
* @throws ApiError
*/
public static getAll(): CancelablePromise<any> {
public static getAll(): CancelablePromise<Array<GetTodoAllResponse>> {
return __request(OpenAPI, {
method: 'GET',
url: '/todos',
Expand Down

0 comments on commit 855ed66

Please sign in to comment.