storj/private/apigen/example/client-api.gen.ts
Ivan Fraixedes d34c1b6825 private/apigen: Generate docs & typescript for example
Generate the documentation and the typescript code for the example of
that we have to generate an API through the API generator.

The JSON Go struct field tags are needed because the typescript
generator require them, otherwise it panics.

The test had to be adjusted according to match the tags so Go consider
the structs the same type, otherwise, it doesn't compile.

Change-Id: I3e4ebff9174885c50ca2058b86b7ec60e025945c
2023-08-25 12:30:21 +00:00

32 lines
841 B
TypeScript

// AUTOGENERATED BY private/apigen
// DO NOT EDIT.
import { HttpClient } from '@/utils/httpClient';
import { Time, UUID } from '@/types/common';
export class {
content: string;
}
export class {
id: UUID;
date: Time;
pathParam: string;
body: string;
}
export class testapiHttpApiV0 {
private readonly http: HttpClient = new HttpClient();
private readonly ROOT_PATH: string = '/api/v0/testapi';
public async (request: , path: string, id: UUID, date: Time): Promise<> {
const path = `${this.ROOT_PATH}/${path}?id=${id}&date=${date}`;
const response = await this.http.post(path, JSON.stringify(request));
if (response.ok) {
return response.json().then((body) => body as );
}
const err = await response.json();
throw new Error(err.error);
}
}