How do I eliminate the request type following the request name in swagger-typescript-api?

I am in search of a method to derive types from a Swagger file without appending a specific request type to the request name.

For instance: If I have an endpoint /assortment and the request type is POST, I currently receive the Api.assortmentCreate() method in the API client.

I wish to eliminate the requirement for the term "create" because it could potentially be different.

If anyone has any insights on how to assist me with this issue, I would greatly appreciate it.

Answer №1

swagger-typescript-api utilizes Eta templates for its template-driven approach. If you wish to override the default templates, you have the option to supply your own template by creating a local directory named templates and placing your custom templates there. For instance, if you want to modify the naming convention of request names from routeCreate to postRoute, you can achieve this by dropping a modified route-name.eta template into the templates directory.

<%
const { routeInfo, utils } = it;
const {
  operationId,
  method,
  route,
  moduleName,
  responsesTypes,
  description,
  tags,
  summary,
  pathArgs,
} = routeInfo;
const { _, fmtToJSDocLine, require } = utils;

// Custom method aliases and function to create unique operation IDs based on method and route
...

if (operationId)
  return _.camelCase(operationId);
if (route === "/")
  return _.camelCase(`${_.lowerCase(method)}Root`);

return createCustomOperationId(method, route, moduleName);
%>

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

Place information from an input field into a specific row within a table

Utilizing Angular 4, I am developing a frontend application for a specific project. The interface features a table with three rows that need to be filled with data from an external source. https://i.stack.imgur.com/Dg576.png Upon clicking the "aggiungi p ...

Issue with Angular 4 Routing: Links are opening in new window instead of within router-outlet

I am currently facing an issue while trying to display the SuburbDataComponent HTML on the DASHBOARD-SIDE-PANEL-COMPONENT.HTML. When I click on Dashboard, it opens a new window but only displays the SuburbDataComponent.html without showing the side panel ...

Guide on integrating Mapbox GL Draw into an Angular 8 project

I'm currently working on an Angular 8 project that utilizes Webpack. My integration of Mapbox GL JS was successful, however, I am facing issues with importing Mabox GL Draw. Here are the versions I am using: "@angular/core": "8.2.14", "mapbox-gl": "^ ...

Tips for receiving string body parameters from Express routes in TypeScript instead of using the 'any' type?

I have a situation where I am passing a unique identifier called productId as a hidden input within a form: <form action="/cart" method="POST"> <button class="btn" type="submit">Add to Cart</button ...

Is there a way to verify the presence of data returned by an API?

I am trying to implement a system in my Index.vue where I need to check if my API request returns any data from the fetchData function. Once the data is fetched, I want to return either a boolean value or something else to my Index.vue. Additionally, I wou ...

What is the process for validating observations with an observer confirmation?

Can you explain what the of() function creates in this scenario and how it operates? public onRemoving(tag): Observable<any> { const confirm = window.confirm('Do you really want to remove this tag?'); return Observable.of(tag).fil ...

My Laravel API app stores all JSON output inside a data tag. How can I eliminate this tag from the output?

Currently, I am developing an API using Laravel to generate JSON data for an Android application. While my friend is handling the Android part of the project, we are facing an issue where the app cannot retrieve the data from the API. We suspect that the p ...

Why does the playwright's onEnd() results not include the duration as specified in the documentation? What am I overlooking?

The built-in onEnd method can have a results object that is accessible within the function. According to the documentation here, this object should include the property duration, which represents the time in milliseconds. However, when I attempt to access ...

Issue with Next.js: Callback function not being executed upon form submission

Within my Next.js module, I have a form that is coded in the following manner: <form onSubmit = {() => { async() => await requestCertificate(id) .then(async resp => await resp.json()) .then(data => console.log(data)) .catch(err => console ...

Troubleshooting Error in Angular 2 API: Issue with Reading Property "1" from Undefined

I have encountered an issue with my project as I am fetching data from an API on a server and trying to populate one of the objects with the retrieved data. However, the console is displaying an error stating that the Object is Undefined. Here is the erro ...

What is the best way to prevent double clicks when using an external onClick function and an internal Link simultaneously

Encountering an issue with nextjs 13, let me explain the situation: Within a card component, there is an external div containing an internal link to navigate to a single product page. Using onClick on the external div enables it to gain focus (necessary f ...

What is the best Google OAuth Playground API to utilize for generating a token that includes the user's name, profile picture, and email address?

I recently came across a helpful tool from Google at https://developers.google.com/oauthplayground/. I am currently practicing authentication for an API with Node.js and Passport.js. I am looking to obtain a token with the user's email and profile pho ...

I am interested in showcasing just a single product image

Here is a snippet of Node.js code: const result = await OrderDB.aggregate([ { $match: { _id: mongoose.Types.ObjectId(id) } }, { $lookup: { from: 'products', localField: 'product', foreig ...

Frozen objects in Typescript 2 behave in a variety of ways depending on their shape

Let's say I'm working with an object whose inner structure is unknown to me because I didn't create it. For instance, I have a reference to an object called attributes that contains HTML attributes. I then made a shallow copy of it and froze ...

Typescript i18next does not meet the requirement of 'string | TemplateStringsArray NextJS'

While attempting to type an array of objects for translation with i18next, I encountered the following error message in the variable navItems when declaring i18next to iterate through the array Type 'NavItemProps[]' does not satisfy the constrain ...

Contrast between utilizing and publishing, demanding and bringing in within Express

I have recently started learning Typescript and Express. I have a simple exported function that looks like this: export function testFunction(req: any, res: any) { console.log(req.body); return res.status(200).send('OK'); }; And ...

Limiting the Rate of Requests to a TCP Server using net.Server

I've been utilizing net.Server as my TCP server. Is there a way to impose a message rate limit? I managed to find solutions for enforcing rate limits in Express (express-rate-limit) and Websocket (websocket-rate-limit), but nothing specifically for ...

What could be causing TypeScript to infer an empty object in this straightforward scenario?

Experience this live showcase. Presented with the code below: type Transformer<T> = (t: T) => T; const identity = <T>(a: T) => a; interface HardInferenceFn { <T>(value: T, transform: Transformer<T> | T): T } declare co ...

When working with create-react-app and TypeScript, you may encounter an error stating: "JSX expressions in 'file_name.tsx' must

After setting up a React project with TypeScript using the CLI command create-react-app client --typescript, I encountered a compilation error when running npm start: ./src/App.js Line 26:13: 'React' must be in scope when using JSX react/r ...

Type Conversion in Typescript

After receiving JSON data that can be in the form of a TextField object or a DateField object, both of which inherit from the Field superclass, I am faced with the task of converting this JSON into a Field object. To further complicate matters, I need to ...