diff --git a/.generation/post-process/typescript.py b/.generation/post-process/typescript.py index 2a9da6e2..49e21ac8 100644 --- a/.generation/post-process/typescript.py +++ b/.generation/post-process/typescript.py @@ -1,8 +1,8 @@ #!/bin/python3 -''' +""" Post-processing of generated code. -''' +""" import sys from pathlib import Path @@ -10,86 +10,114 @@ from textwrap import dedent, indent from util import modify_file, version -INDENT = ' ' +INDENT = " " + def runtime_ts(file_contents: List[str]) -> Generator[str, None, None]: - '''Modify the runtime.ts file.''' + """Modify the runtime.ts file.""" for line in file_contents: - if line.startswith('export const DefaultConfig ='): - line = dedent(f'''\ + if line.startswith("export const DefaultConfig ="): + line = dedent(f"""\ export const DefaultConfig = new Configuration({{ headers: {{ 'User-Agent': 'geoengine/openapi-client/typescript/{version()}' }} }}); - ''') + """) yield line + # fixes due to https://github.com/OpenAPITools/openapi-generator/issues/14831 def plot_update_ts(file_contents: List[str]) -> Generator[str, None, None]: - '''Modify the PlotUpdate.ts file.''' + """Modify the PlotUpdate.ts file.""" for line in file_contents: dedented_line = dedent(line) - if dedented_line.startswith('if (instanceOfPlot(value))'): - line = indent(dedent('''\ + if dedented_line.startswith("if (instanceOfPlot(value))"): + line = indent( + dedent("""\ if (typeof value === 'object' && instanceOfPlot(value)) { - '''), INDENT) + """), + INDENT, + ) yield line + # fixes due to https://github.com/OpenAPITools/openapi-generator/issues/14831 def layer_update_ts(file_contents: List[str]) -> Generator[str, None, None]: - '''Modify the LayerUpdate.ts file.''' + """Modify the LayerUpdate.ts file.""" for line in file_contents: dedented_line = dedent(line) - if dedented_line.startswith('if (instanceOfProjectLayer(value))'): - line = indent(dedent('''\ + if dedented_line.startswith("if (instanceOfProjectLayer(value))"): + line = indent( + dedent("""\ if (typeof value === 'object' && instanceOfProjectLayer(value)) { - '''), INDENT) + """), + INDENT, + ) yield line + # Fix: interface cannot inherit union type def task_status_with_id_ts(file_contents: List[str]) -> Generator[str, None, None]: - '''Modify the TaskStatusWithId.ts file.''' + """Modify the TaskStatusWithId.ts file.""" for line in file_contents: dedented_line = dedent(line) - if dedented_line.startswith('export interface TaskStatusWithId extends TaskStatus'): - line = dedent('''\ + if dedented_line.startswith( + "export interface TaskStatusWithId extends TaskStatus" + ): + line = dedent("""\ export type TaskStatusWithId = { taskId: string } & TaskStatus; export interface _TaskStatusWithId /* extends TaskStatus */ { - ''') + """) yield line + def vec_update_ts(file_contents: List[str]) -> Generator[str, None, None]: - '''Modify the VecUpdate.ts file.''' + """Modify the VecUpdate.ts file.""" for line in file_contents: dedented_line = dedent(line) - if dedented_line.startswith('if (instanceOfPlot(value)) {'): - line = indent("if (typeof value === 'object' && instanceOfPlot(value)) {\n", INDENT) + if dedented_line.startswith("if (instanceOfPlot(value)) {"): + line = indent( + "if (typeof value === 'object' && instanceOfPlot(value)) {\n", INDENT + ) + + yield line + + +def ogcwfsapi_ts(file_contents: List[str]) -> Generator[str, None, None]: + """Modify the OGCWFSApi.ts file.""" + for line in file_contents: + dedented_line = dedent(line) + if dedented_line.startswith("path: `/wfs/{workflow}?request=GetFeature`"): + line = line.replace("?request=GetFeature", "") + elif dedented_line.startswith("path: `/wfs/{workflow}?request=GetCapabilities"): + line = line.replace("?request=GetCapabilities", "") yield line input_file = Path(sys.argv[1]) file_modifications = { - 'LayerUpdate.ts': layer_update_ts, - 'PlotUpdate.ts': plot_update_ts, - 'runtime.ts': runtime_ts, - 'TaskStatusWithId.ts': task_status_with_id_ts, - 'VecUpdate.ts': vec_update_ts, + "LayerUpdate.ts": layer_update_ts, + "OGCWFSApi.ts": ogcwfsapi_ts, + "PlotUpdate.ts": plot_update_ts, + "runtime.ts": runtime_ts, + "TaskStatusWithId.ts": task_status_with_id_ts, + "VecUpdate.ts": vec_update_ts, } if modifier_function := file_modifications.get(input_file.name): modify_file(input_file, modifier_function) else: - pass # leave file untouched + pass # leave file untouched exit(0) diff --git a/typescript/dist/apis/OGCWFSApi.js b/typescript/dist/apis/OGCWFSApi.js index 8c784238..8085e317 100644 --- a/typescript/dist/apis/OGCWFSApi.js +++ b/typescript/dist/apis/OGCWFSApi.js @@ -56,7 +56,7 @@ class OGCWFSApi extends runtime.BaseAPI { } } const response = yield this.request({ - path: `/wfs/{workflow}?request=GetCapabilities`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -150,7 +150,7 @@ class OGCWFSApi extends runtime.BaseAPI { } } const response = yield this.request({ - path: `/wfs/{workflow}?request=GetFeature`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/typescript/dist/esm/apis/OGCWFSApi.js b/typescript/dist/esm/apis/OGCWFSApi.js index f2513c2d..d114c363 100644 --- a/typescript/dist/esm/apis/OGCWFSApi.js +++ b/typescript/dist/esm/apis/OGCWFSApi.js @@ -53,7 +53,7 @@ export class OGCWFSApi extends runtime.BaseAPI { } } const response = yield this.request({ - path: `/wfs/{workflow}?request=GetCapabilities`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -147,7 +147,7 @@ export class OGCWFSApi extends runtime.BaseAPI { } } const response = yield this.request({ - path: `/wfs/{workflow}?request=GetFeature`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/typescript/src/apis/OGCWFSApi.ts b/typescript/src/apis/OGCWFSApi.ts index a0aac151..11487c6d 100644 --- a/typescript/src/apis/OGCWFSApi.ts +++ b/typescript/src/apis/OGCWFSApi.ts @@ -109,7 +109,7 @@ export class OGCWFSApi extends runtime.BaseAPI { } } const response = await this.request({ - path: `/wfs/{workflow}?request=GetCapabilities`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))).replace(`{${"version"}}`, encodeURIComponent(String(requestParameters['version']))).replace(`{${"service"}}`, encodeURIComponent(String(requestParameters['service']))).replace(`{${"request"}}`, encodeURIComponent(String(requestParameters['request']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -238,7 +238,7 @@ export class OGCWFSApi extends runtime.BaseAPI { } } const response = await this.request({ - path: `/wfs/{workflow}?request=GetFeature`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), + path: `/wfs/{workflow}`.replace(`{${"workflow"}}`, encodeURIComponent(String(requestParameters['workflow']))), method: 'GET', headers: headerParameters, query: queryParameters,