What is the reason for openapi-generator not generating a package.json file when using typescript-angular?

When it comes to generating code for typescript-angular using the openapi-generator-maven-plugin, my process involves configuring an XML file in the following manner:

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

Despite a successful output from the generator run, I still face the absence of a crucial package.json file necessary for executing npm install. This was previously handled seamlessly with a swagger plugin that auto-generated the package.json file.

Therefore, my inquiry pertains to why the package.json file is not automatically generated and what steps can be taken to remedy this issue?

The log output post-generation seems satisfactory as follows:

[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

Answer №1

It appears that the plugin description is not very explicit to me, as it seems like:

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

is incorrect and should be replaced with:

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

or with:

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

to ensure proper generation of package.json and tsconfig.json.

Therefore, the original example needs to be modified 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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Storing the outcome of a promise in a variable within a nodejs environment

const fetchData = async () => { try { const usersData = await users.find({}).toArray(); state.response.end(JSON.stringify({ message: usersData })); if (!!usersData) { const collageData = await ...

Tips for specifying Content-Encoding metadata headers using webpack compression

During development, I enjoy running npm run watch, but my uncompressed bundle size is quite large at 7.5MB. To add HTTPS support via ngrok (for team usage as well), the process of checking CSS updates with a simple page reload becomes time-consuming. I wi ...

Retrieve information regarding the chart js instance and component variable

I currently have two functions in my ChartJS instance for handling click events. The first function works well for accessing component variables. onClick: () => { console.log(this.test); }, However, I am now facing an issue where I need to retri ...

Renovating Code: Swapping out a data type (and refreshing imports) - Tips and Tricks

For example, in our code base, we currently utilize a type OldType from the npm package @old-package. Our goal is to substitute it with our custom type NewType, which can be accessed through @new-package. Illustration Existing imports import { AnyImport ...

Displaying dynamic key-value pairs in each row of an Angular mat-table

I need help displaying a key-value pair data in JSON format dynamically within a table using Angular mat-table. The keys will vary, so there is no set list of keys that will be included in the JSON. This is an example of the data: var data = { "cars" : 2 ...

Mapping an array of Type T in Typescript using typings

Suppose we have a type T: type T = { type: string, } and we create a function that takes an array of T and returns an object where the keys are the values of each T.type and the values are objects of type T. const toMap = (...args: T[]) => args.red ...

The Angular project experiences crashes when attempting to install certain npm packages. Interestingly, these same packages install successfully in a test project but fail in the actual projects

It is the first time we are encountering this issue where both projects have the same angular cli version '7.2.0'. Does anyone know how to proceed and fix this situation? Below is the JSON file of the real working project: "name": "financial-s ...

Angular: Enable function to await Observable completion before returning result

I require assistance with the user function below: getUser(uuid: string): Observable<WowUserDataModel> { let user: WowUserDataModel = { login: null, userUuid: uuid, firstName: null, lastName: null, displayName: nul ...

Limit pasted content in an Angular contenteditable div

Is there a way to limit the input in a contenteditable div? I am developing my own WYSIWYG editor and want to prevent users from pasting content from external websites and copying styles. I want to achieve the same effect as if the content was pasted into ...

What is the most efficient way to transfer data to another page without having to repeatedly retrieve it from a

Looking for a way to pass additional data to another page when clicking on an item. I attempted to extend the father class to the child class, but it significantly slowed down the process due to the frequent class calls. This application is a dashboard w ...

Having trouble with installing redux using npm?

When I try to run npm install redux, an error occurs: npm ERR! fetch failed https://registry.npmjs.org/lodash-es/-/lodash-es-4.6.0.tgz npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404 It seems there might be a pr ...

Reactjs: Issue with functionality of input field

My project includes an input field for adding email tags, which I initially created using React JS. The functionality worked seamlessly in the JavaScript file, but when I converted it to TypeScript, I encountered a issue where I couldn't type or paste ...

"Implementing the functionality to handle checkbox click events and changes in Angular

Encountering an unusual issue with checkboxes in angular2 (beta 17). Attempting to align checkboxes with elements in an array and bind the change or click event. Here is an example array: myObjects=[ {value:true}, {value:true}, {value:false} ...

What is the process for linking my component to my socket.io server?

I am facing a challenge in setting up a socket.io server to facilitate communication between two components: a command interface for sending data, and an overlay component for receiving it. Below is the code snippet: interface.component.html : <input ...

An easy way to select multiple checkboxes from an array using Angular 6

When editing data, I have a form that includes checkboxes. I need to ensure that the previously selected checkboxes are checked in the edit profile form based on the array retrieved from the database. Code snippet from app.component.html: <form [formG ...

Personalized Firefox Scrollbar - Rounded Corners

I have successfully customized the default CSS of browser scrollbars for Chrome and Edge, but I am facing issues with Firefox. Is there a way to sync the scrollbar styling in Firefox with Chrome and Edge? Currently, I am unable to apply border radius to th ...

A custom Typescript type for immutable values within an object

I am struggling with finding the right data type for my function, where I need to work with static types. I have experimented with Type, interface, class, Record, and others, but none seem to fit perfectly. GEOLOCATIONS is a constant record that maps cou ...

Receiving updates on the status of a spawned child process in Node.js

Currently, I'm running the npm install -g create-react-app command from a JavaScript script and I am looking to extract the real-time progress information during the package installation process. Here is an example of what I aim to capture: https://i ...

No routes found to match. URL Segment: ''. This issue occurs when attempting to utilize child routes with Angular 2

I am having issues with this specific plunker that seems to not be working correctly. To try and fix the problem, I attempted to comment out a section of code... RouterModule.forRoot([ { path: "", component: TestComponent, ...

Can you tell me the equivalent in Angular of the hasClass method?

Looking to target elements with a designated class and dynamically update their contents ...