swagger-codegen lacks the capability to generate query parameter objects

I am struggling to create a TypeScript-Angular SDK using the OpenAPI spec from Loopback4, but Swagger-codegen keeps disregarding my query parameter objects.

In the specification below, you can see the path GET /plans which can contain a filter query parameter. In the generated class, you see the method

planControllerFind(?:, observe: ...)
which only has ?: as the first parameter instead of
planControllerFind(filter?: FilterClass, observe: ...)

I have experimented with different specification structures and also tried various versions of Swagger-codegen (3.0.11, 3.0.16, 3.0.18) but nothing seems to resolve the issue. Even the online version generates incomplete code.

Could anyone provide me with some guidance?

The code was generated using:

swagger-codegen generate -i http://localhost:3000/explorer/openapi.json -l typescript-angular -o app/src/app/core/lb4-sdk -c ./swagger-sdk.options.json

where the /swagger-sdk.options.json file looks like this:

{
  "npmName": "@ilem0n/ng-budget-api",
  "npmVersion": "0.0.1",
  "snapshot": true,
  "ngVersion": "5.0.0"
}

Here is the spec generated from Loopback4:

// The full OpenAPI spec goes here...

From this spec, the following class for the planController was generated:

// Automatically generated Angular service Class...

Answer №1

After encountering an issue with swagger-api/swagger-codegen (see here), I reached out for help but unfortunately couldn't find a solution.

Luckily, switching to OpenAPI Generator resolved the problem effortlessly. No more issues to worry about!

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

Discover similarities between two arrays

My goal is to compare two arrays and generate a JSON array marking true if there's a match and false if there isn't. The second array will always have values that match some from the first, and it will be smaller as it's derived from the fir ...

Angular data binding with [object object]

Upon receiving data from my API, the console displays the following structure: [ { id:"123", name:"asd", address:"st.dddss", status:1 } ] After attempting to iterate through it using ngFor, an error is thrown: E ...

Encountering a "subscribe is not a function" error while attempting to utilize a JSON file in Angular 2

My attempt to import a JSON file into my service is resulting in the following error: Error: Uncaught (in promise): TypeError: this._qs.getBasicInfo(...).subscribe is not a function(…) The current state of my service file is as follows @Injectable() ...

What is the process for creating an Angular library using "npm pack" within a Java/Spring Boot application?

In my angular project, we have 5 custom libraries tailored to our needs. Using the com.github.eirslett maven plugin in our spring boot application, we build these libraries through the pom.xml file and then copy them to the dist/ folder. However, we also ...

What is the best way to identify the data type of elements in an array using TypeScript?

When working with TypeScript, it is common to reference interface properties using syntax like Person['gender']. This allows for clear definition of types in TypeScript, as shown in the following example: interface Person { gender: 'male& ...

Implementing Typescript for managing state in React components

Currently, I have a state set up like this: const [newInvoice, setInvoice] = useState<InvoiceType | null>(invoice) The structure of my InvoiceType is as follows: customer_email: string customer_name: string description: string due_date: stri ...

The parent component's state does not reflect updates made by the child component's successful dispatch of a reducer through Redux Toolkit

I encountered a strange issue where the state slice is behaving correctly (verified by unit tests and manual testing). However, it appears that the react selector is not properly subscribing to it. Here is the parent component code: import { useSelector } ...

TypeScript definition for a dispatcher within a map

I am in the process of creating a typed function that will utilize an object based on its key: const commandOrQuery = { CREATE_USER_WITH_PASSWORD: CreateUserCommandHandler, GET_USERS: GetUsersQueryHandler, }; The structure of commandOrQuery is as foll ...

Mastering the art of calculating month differences on TypeScript dates in an Angular environment

Currently, I am working with Angular 7. Suppose I have a fixed rate X, for example, an amount I need to pay each month. Now, if I have two specified dates startDate and endDate, I want to calculate the total payment due for this given time period. To prov ...

Encountering difficulties with installing bootstrap-vue

While attempting to integrate Bootstrap-Vue into my project that includes Vuex, Vue-Router, TypeScript, and Babel, I encounter an error in the browser. To replicate docker run -it --rm -p 8080:8080 node:17.7.2-alpine yarn global add @vue/cli vue create ...

Unable to locate the name 'Cheerio' in the @types/enzyme/index.d.t file

When I try to run my Node application, I encounter the following error: C:/Me/MyApp/node_modules/@types/enzyme/index.d.ts (351,15): Cannot find name 'Cheerio'. I found a suggestion in a forum that recommends using cheerio instead of Cheerio. H ...

What is the best way to specify the type of a generic function in TypeScript?

Issue I am facing a challenge with the implementation of a generic function type: type Validator<TInput, TOutput extends TInput> = (value: TInput) => Validated<TOutput>; My attempt to implement this type resulted in the following code: con ...

various positions for ngb properties

My input field has both a tooltip and a dropdown attached to it using the ngb attributes: <input placement="right" ngbTooltip="Search" [ngbTypeahead]="search" /> The issue I'm facing is that I want the tooltip to appear on the right ...

Is there a way to trigger the "ngOnInit()" function again after navigating to the same URL but with a different parameter?

Within my application, there exists a URL structure such as /organization/campaign/{campaign handle}. The objective is to guide the user to a default campaign handle whenever they access the URL with an invalid {campaign handle}. For instance, if a user ...

When testing my POST request online, it functions properly. However, I am facing difficulties in getting it to work in next.js as I keep receiving a 405

I am currently working on establishing a connection to Zoho Creator in order to retrieve some data. After successfully testing the request on and receiving the correct response, I encountered an issue while trying to implement it within a next.js applicat ...

Text in Angular vanishes upon reopening

I have a code snippet where I am trying to allow the user to edit and save a paragraph displayed on a side panel of the main page. Although the code works fine, allowing users to update the text and see it reflected in the network upon saving, there seems ...

Guide on deploying a web application with Angular 6 as the front end, ASP.NET Core in the backend, and SQL Server as the database on Nginx using Docker

I am currently working on a web application that utilizes Angular 6 for the client side, ASP .NET Core for the backend, and SQL Server as the database. My goal is to deploy this web application on an Nginx server using Docker technology. I have successfull ...

TS - decorator relies on another irrespective of their position within the class

Is it possible to consistently run function decorator @A before @B, regardless of their position within the class? class Example { @A() public method1(): void { ... } @B() public method2(): void { ... } @A() public method3(): void { ... } } In the sc ...

Navigating manually through URLs in Angular2's routing system

I have a basic application This is how my app.component.html is structured: <a [routerLink]="['/Test']">CLICK ME</a> <div class="main-container"> <router-outlet></router-outlet> </div> And this is how my ...

Storing MySQL data in an array using Node.js

I'm facing an issue where I am trying to populate an array with the results of an SQL query, but it keeps coming out empty. I suspect that my usage of async and await might be incorrect. Below is the code snippet: exports.get_all_post = async ...