为什么openapi-generator不创建带有typescript-angular的package.json? [英] Why does openapi-generator not create a package.json with typescript-angular?

查看:112
本文介绍了为什么openapi-generator不创建带有typescript-angular的package.json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am generating code for typescript-angular with the openapi-generator-maven-plugin like this:

<?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文件.

What I am missing now is a package.json file so that I could do a npm install. From some older swagger examples it looks like with the swagger plugin a package.json file was generated.

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

So my question is why is the package.json file not generated and what could I do to get one?

生成器运行的输出对我来说没问题:

The output of the generator run looks ok to me:

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

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

[INFO] OpenAPI Generator:typescript-angular(客户端)

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

[INFO]生成器'typescript-angular'被认为是稳定的.

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

[INFO]提示:未定义环境变量'TS_POST_PROCESS_FILE'(可选).例如.要格式化源代码,请尝试导出TS_POST_PROCESS_FILE ="/usr/local/bin/prettier --write""(Linux/Mac)

[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]注意:要启用文件后处理,必须将"enablePostProcessFile"设置为true(用于CLI的--enable-post-process-file).

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

[INFO]为Angular 8.0.0生成代码...

[INFO] generating code for Angular 8.0.0 ...

[INFO](您可以通过设置AdditionalProperty ngVersion来选择角度版本)

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

[INFO]写入文件C:\ my-client-rest \ api \ default.service.ts

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

[INFO]编写文件C:\ my-client-rest \ model \ models.ts

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

[INFO]编写文件C:\ my-client-rest \ api \ api.ts

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

[INFO]写入文件C:\ my-client-rest \ index.ts

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

[INFO]写入文件C:\ my-client-rest \ api.module.ts

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

[INFO]写入文件C:\ my-client-rest \ configuration.ts

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

[INFO]写入文件C:\ my-client-rest \ variables.ts

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

[INFO]写入文件C:\ my-client-rest \ encoder.ts

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

[INFO]写入文件C:\ my-client-rest.gitignore

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

[INFO]写入文件C:\ my-client-rest \ git_push.sh

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

[INFO]写入文件C:\ my-client-rest \ README.md

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

[INFO]写入文件C:\ my-client-rest.openapi-generator \ VERSION

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

推荐答案

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

Looks like the description of the plugin is not very clear (at least to me), because it seems that:

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

错误,应替换为:

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

或带有:

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

使package.json和tsconfig.json的生成工作正常.

to make the generation of package.json and tsconfig.json work.

因此,我原来的示例应更改为:

So my original example should be changed to:

<?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>

这篇关于为什么openapi-generator不创建带有typescript-angular的package.json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆