Closed8

openapi-generator for Deno, Deno のバージョンが上がったら動かなくなった

Tomofumi Chiba@仙台Tomofumi Chiba@仙台
$ java -jar openapi-generator-cli.jar generate -i https://petstore.swagger.io/v2/swagger.json -g typescript --additional-properties=platform=deno -o generated-src
$ deno --version
deno 1.6.1 (release, x86_64-unknown-linux-gnu)
v8 8.8.278.2
typescript 4.1.2
$ deno run --allow-net=petstore.swagger.io test.ts
Check file:///C:/Users/ts-tomofumi.chiba/data/work/test.ts
error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { createConfiguration, Configuration } from "./configuration.ts"
                              ~~~~~~~~~~~~~
    at file:///C:/Users/ts-tomofumi.chiba/data/work/generated-src/index.ts:4:31

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { PromiseMiddleware as Middleware } from './middleware.ts';
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///C:/Users/ts-tomofumi.chiba/data/work/generated-src/index.ts:8:10

Found 2 errors.
Tomofumi Chiba@仙台Tomofumi Chiba@仙台
$ diff index.ts index.ts.org
4,5c4
< export { createConfiguration } from "./configuration.ts"
< export type { Configuration } from "./configuration.ts"
---
> export { createConfiguration, Configuration } from "./configuration.ts"
9c8
< export type { PromiseMiddleware as Middleware } from './middleware.ts';
---
> export { PromiseMiddleware as Middleware } from './middleware.ts';

こんな感じで修正されれば動く。

Tomofumi Chiba@仙台Tomofumi Chiba@仙台
./mvnw install
./mvnw install --projects modules/openapi-generator
./bin/generate-samples.sh
./bin/utils/export_generator.sh typescript
./mvnw integration-test -rf :TypeScriptDenoPetstoreClientTests -P typescript-client-tests-deno
Tomofumi Chiba@仙台Tomofumi Chiba@仙台

PR

fixed XXXX

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)

Tomofumi Chiba@仙台Tomofumi Chiba@仙台

issue

title: [BUG][typescript(experimental)] Support Deno v1.6

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The Generated Deno code does not work with Deno v1.6 .

openapi-generator version

v5.0.0

OpenAPI declaration file content or url

https://petstore.swagger.io/v2/swagger.json

Steps to reproduce
$ java -jar openapi-generator-cli-5.0.0.jar generate -i https://petstore.swagger.io/v2/swagger.json -g typescript --additional-properties=platform=deno -o generated-src

$ echo '
import * as petstore from "./generated-src/index.ts";

const configuration = petstore.createConfiguration();
const petApi = new petstore.PetApi(configuration);
const pets = await petApi.findPetsByStatus(["available"]);
console.log(pets.slice(0, 5));
' > test.ts

$ deno --version
deno 1.6.2 (release, x86_64-unknown-linux-gnu)
v8 8.8.278.2
typescript 4.1.3

$ deno run --allow-net=petstore.swagger.io test.ts
Check file:///home/gitpod/work/test.ts
error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { createConfiguration, Configuration } from "./configuration.ts"
                              ~~~~~~~~~~~~~
    at file:///home/gitpod/work/generated-src/index.ts:4:31

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { PromiseMiddleware as Middleware } from './middleware.ts';
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///home/gitpod/work/generated-src/index.ts:8:10

Found 2 errors.
Generation Details

actual

export { createConfiguration, Configuration } from "./configuration.ts"
export { PromiseMiddleware as Middleware } from './middleware.ts';

expect

export { createConfiguration } from "./configuration.ts"
export type { Configuration } from "./configuration.ts"
export type { PromiseMiddleware as Middleware } from './middleware.ts';
Related issues/PRs

https://github.com/denoland/deno/pull/8482

Suggest a fix

I will create a PR.

このスクラップは2020/12/28にクローズされました