Skip to content
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

Migrating from openapi-typescript-codegen to @hey-api/openapi-ts #768

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions frontend/openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
client: "@hey-api/client-axios",
input: "http://localhost:5000/openapi.json",
output: "./src/api",
/*
services: {
methodNameBuilder: (operation) => {
return `${operation.name}_api`;
},
},
*/
// plugins: ["@tanstack/react-query"],
});
607 changes: 433 additions & 174 deletions frontend/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite --host",
"build": "tsc && NODE_OPTIONS='--max-old-space-size=8192' vite build",
"preview": "vite preview",
"generate-api": "openapi --input http://localhost:5000/openapi.json --output ./src/api --client axios --name ApiService --postfixModels _api",
"generate-api": "openapi-ts --name ApiService",
"typecheck": "tsc --noEmit",
"lint": "eslint 'src/**/*.+(ts|tsx|js|jsx|json)' 'tests/**/*.+(ts|tsx|js|jsx|json)' --max-warnings=0",
"depscheck": "dependency-cruise src",
Expand All @@ -21,6 +21,7 @@
"dependencies": {
"@equinor/esv-intersection": "^3.0.10",
"@headlessui/react": "^1.7.8",
"@hey-api/client-axios": "^0.2.9",
"@mui/base": "^5.0.0-beta.3",
"@mui/icons-material": "^5.14.9",
"@tanstack/query-core": "^5.17.19",
Expand Down Expand Up @@ -48,6 +49,7 @@
"wonka": "^6.3.4"
},
"devDependencies": {
"@hey-api/openapi-ts": "^0.53.11",
"@playwright/experimental-ct-react": "^1.39.0",
"@playwright/test": "^1.39.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
Expand All @@ -71,7 +73,6 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^10.3.3",
"openapi-typescript-codegen": "^0.26.0",
"postcss": "^8.4.21",
"prettier": "2.8.3",
"sass": "^1.62.0",
Expand Down
149 changes: 78 additions & 71 deletions frontend/src/api/ApiService.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,83 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BaseHttpRequest } from './core/BaseHttpRequest';
import type { OpenAPIConfig } from './core/OpenAPI';
import { AxiosHttpRequest } from './core/AxiosHttpRequest';
import { DefaultService } from './services/DefaultService';
import { ExploreService } from './services/ExploreService';
import { GraphService } from './services/GraphService';
import { Grid3DService } from './services/Grid3DService';
import { GroupTreeService } from './services/GroupTreeService';
import { InplaceVolumetricsService } from './services/InplaceVolumetricsService';
import { ObservationsService } from './services/ObservationsService';
import { ParametersService } from './services/ParametersService';
import { PolygonsService } from './services/PolygonsService';
import { PvtService } from './services/PvtService';
import { RftService } from './services/RftService';
import { SeismicService } from './services/SeismicService';
import { SurfaceService } from './services/SurfaceService';
import { TimeseriesService } from './services/TimeseriesService';
import { VfpService } from './services/VfpService';
import { WellService } from './services/WellService';
import { WellCompletionsService } from './services/WellCompletionsService';
import { Interceptors } from './core/OpenAPI';
import { } from './core/';

import { DefaultService } from './services.gen';
import { ExploreService } from './services.gen';
import { GraphService } from './services.gen';
import { Grid3DService } from './services.gen';
import { GroupTreeService } from './services.gen';
import { InplaceVolumetricsService } from './services.gen';
import { ObservationsService } from './services.gen';
import { ParametersService } from './services.gen';
import { PolygonsService } from './services.gen';
import { PvtService } from './services.gen';
import { RftService } from './services.gen';
import { SeismicService } from './services.gen';
import { SurfaceService } from './services.gen';
import { TimeseriesService } from './services.gen';
import { VfpService } from './services.gen';
import { WellService } from './services.gen';
import { WellCompletionsService } from './services.gen';

type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;

export class ApiService {
public readonly default: DefaultService;
public readonly explore: ExploreService;
public readonly graph: GraphService;
public readonly grid3D: Grid3DService;
public readonly groupTree: GroupTreeService;
public readonly inplaceVolumetrics: InplaceVolumetricsService;
public readonly observations: ObservationsService;
public readonly parameters: ParametersService;
public readonly polygons: PolygonsService;
public readonly pvt: PvtService;
public readonly rft: RftService;
public readonly seismic: SeismicService;
public readonly surface: SurfaceService;
public readonly timeseries: TimeseriesService;
public readonly vfp: VfpService;
public readonly well: WellService;
public readonly wellCompletions: WellCompletionsService;
public readonly request: BaseHttpRequest;
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = AxiosHttpRequest) {
this.request = new HttpRequest({
BASE: config?.BASE ?? '/api',
VERSION: config?.VERSION ?? '0.1.0',
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
CREDENTIALS: config?.CREDENTIALS ?? 'include',
TOKEN: config?.TOKEN,
USERNAME: config?.USERNAME,
PASSWORD: config?.PASSWORD,
HEADERS: config?.HEADERS,
ENCODE_PATH: config?.ENCODE_PATH,
});
this.default = new DefaultService(this.request);
this.explore = new ExploreService(this.request);
this.graph = new GraphService(this.request);
this.grid3D = new Grid3DService(this.request);
this.groupTree = new GroupTreeService(this.request);
this.inplaceVolumetrics = new InplaceVolumetricsService(this.request);
this.observations = new ObservationsService(this.request);
this.parameters = new ParametersService(this.request);
this.polygons = new PolygonsService(this.request);
this.pvt = new PvtService(this.request);
this.rft = new RftService(this.request);
this.seismic = new SeismicService(this.request);
this.surface = new SurfaceService(this.request);
this.timeseries = new TimeseriesService(this.request);
this.vfp = new VfpService(this.request);
this.well = new WellService(this.request);
this.wellCompletions = new WellCompletionsService(this.request);
}
}

public readonly default: DefaultService;
public readonly explore: ExploreService;
public readonly graph: GraphService;
public readonly grid3D: Grid3DService;
public readonly groupTree: GroupTreeService;
public readonly inplaceVolumetrics: InplaceVolumetricsService;
public readonly observations: ObservationsService;
public readonly parameters: ParametersService;
public readonly polygons: PolygonsService;
public readonly pvt: PvtService;
public readonly rft: RftService;
public readonly seismic: SeismicService;
public readonly surface: SurfaceService;
public readonly timeseries: TimeseriesService;
public readonly vfp: VfpService;
public readonly well: WellService;
public readonly wellCompletions: WellCompletionsService;

public readonly request: BaseHttpRequest;

constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = ) {
this.request = new HttpRequest({
BASE: config?.BASE ?? '/api',
VERSION: config?.VERSION ?? '0.1.0',
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
CREDENTIALS: config?.CREDENTIALS ?? 'include',
TOKEN: config?.TOKEN,
USERNAME: config?.USERNAME,
PASSWORD: config?.PASSWORD,
HEADERS: config?.HEADERS,
ENCODE_PATH: config?.ENCODE_PATH,
interceptors: {
request: config?.interceptors?.request ?? new Interceptors(),
response: config?.interceptors?.response ?? new Interceptors(),
},
});

this.default = new DefaultService(this.request);
this.explore = new ExploreService(this.request);
this.graph = new GraphService(this.request);
this.grid3D = new Grid3DService(this.request);
this.groupTree = new GroupTreeService(this.request);
this.inplaceVolumetrics = new InplaceVolumetricsService(this.request);
this.observations = new ObservationsService(this.request);
this.parameters = new ParametersService(this.request);
this.polygons = new PolygonsService(this.request);
this.pvt = new PvtService(this.request);
this.rft = new RftService(this.request);
this.seismic = new SeismicService(this.request);
this.surface = new SurfaceService(this.request);
this.timeseries = new TimeseriesService(this.request);
this.vfp = new VfpService(this.request);
this.well = new WellService(this.request);
this.wellCompletions = new WellCompletionsService(this.request);
}
}
25 changes: 0 additions & 25 deletions frontend/src/api/core/ApiError.ts

This file was deleted.

17 changes: 0 additions & 17 deletions frontend/src/api/core/ApiRequestOptions.ts

This file was deleted.

11 changes: 0 additions & 11 deletions frontend/src/api/core/ApiResult.ts

This file was deleted.

26 changes: 0 additions & 26 deletions frontend/src/api/core/AxiosHttpRequest.ts

This file was deleted.

14 changes: 0 additions & 14 deletions frontend/src/api/core/BaseHttpRequest.ts

This file was deleted.

Loading
Loading