为什么 openapi-generator 不使用 typescript-angular 创建 package.json?

Why does openapi-generator not create a package.json with typescript-angular?

我正在使用 openapi-generator-maven-plugin 为 typescript-angular 生成代码,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <build>
    <plugins>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>4.2.0</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/../my_server/openapi.json</inputSpec>
              <generatorName>typescript-angular</generatorName>
              <output>${project.basedir}</output>
              <npmName>myClientRest</npmName>
              <npmRepository>http://localhost:8444/repository/npm-releases/</npmRepository>
              <providedInRoot>true</providedInRoot>
              <apiModulePrefix>my</apiModulePrefix>
              <stringEnums>true</stringEnums>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

我现在缺少的是 package.json 文件,这样我就可以执行 npm install。 从一些较旧的 swagger 示例来看,swagger 插件生成了一个 package.json 文件。

所以我的问题是为什么 package.json 文件没有生成,我该怎么做才能得到一个?

生成器的输出 运行 在我看来还不错:

[INFO] --- openapi-generator-maven-plugin:4.2.0:generate (default) @ client ---

[INFO] OpenAPI Generator: typescript-angular (client)

[INFO] Generator 'typescript-angular' is considered stable.

[INFO] Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write"' (Linux/Mac)

[INFO] Note: To enable file post-processing, 'enablePostProcessFile' must be set to true (--enable-post-process-file for CLI).

[INFO] generating code for Angular 8.0.0 ...

[INFO] (you can select the angular version by setting the additionalProperty ngVersion)

[INFO] writing file C:\my-client-rest\api\default.service.ts

[INFO] writing file C:\my-client-rest\model\models.ts

[INFO] writing file C:\my-client-rest\api\api.ts

[INFO] writing file C:\my-client-rest\index.ts

[INFO] writing file C:\my-client-rest\api.module.ts

[INFO] writing file C:\my-client-rest\configuration.ts

[INFO] writing file C:\my-client-rest\variables.ts

[INFO] writing file C:\my-client-rest\encoder.ts

[INFO] writing file C:\my-client-rest.gitignore

[INFO] writing file C:\my-client-rest\git_push.sh

[INFO] writing file C:\my-client-rest\README.md

[INFO] writing file C:\my-client-rest.openapi-generator\VERSION

看起来插件的描述不是很清楚(至少对我来说),因为似乎:

<configuration>
  <npmName>myClientRest</npmName>
</configuration>

错误,应替换为:

<configuration>
  <additionalProperties>npmName=myClientRest</additionalProperties>
</configuration>

或与:

<configuration>
  <configOptions>
    <npmName>tmsClientRest</npmName>
  </configOptions>
</configuration>

使 package.json 和 tsconfig.json 的生成工作。

所以我原来的例子应该改成:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<build>
  <plugins>
    <plugin>
      <groupId>org.openapitools</groupId>
      <artifactId>openapi-generator-maven-plugin</artifactId>
      <version>4.2.1</version>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <inputSpec>${project.basedir}/../my_server/openapi.json</inputSpec>
            <generatorName>typescript-angular</generatorName>
            <output>${project.basedir}</output>
            <configOptions>
              <npmName>tmsClientRest</npmName>
              <npmRepository>http://www.test-tms-archiv-net.de:8444/repository/npm-releases/</npmRepository>
              <providedInRoot>true</providedInRoot>
              <apiModulePrefix>tms</apiModulePrefix>
              <stringEnums>true</stringEnums>
            </configOptions>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
</project>