Encountered an issue with retrieving schema during self-referencing validation with openapi generator

I created an openapi specification and now I am looking to generate a client for it.

openapi.yaml

After some research, I decided to use the openapi generator to create a typescript-axios client. This is the command I used:

openapi-generator-cli generate -g typescript-axios -i openapi.yaml -o src/client

Unfortunately, the generation process resulted in multiple errors, mostly related to self-referencing checks:

[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `createdAt` in self reference check
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `lastModified` in self reference check
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `lastModified` in self reference check
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `slink` in self reference check
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `slink` in self reference check
[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `id` in self reference check

Upon inspecting the generated src/client directory, I encountered numerous type errors and import errors, such as:

import { Id } from './Id';

despite the absence of Id.ts file.

I acknowledge that these issues stem from my specification's extensive self-referencing, but eliminating them completely is not feasible.

Despite searching for solutions, I was unable to find much helpful guidance.

Is there a way to resolve these errors or should I consider using a different tool? Your assistance is greatly appreciated.

Answer №1

If you see an error message like:

[main] ERROR o.o.codegen.utils.ModelUtils - Failed to obtain schema from `createdAt` in self reference check

it is likely because you are using a reference to an object that does not exist, such as:

$ref: "#/components/schemas/createdAt

Make sure that the object "createdAt" is defined correctly (e.g., it should be a string, not an object):

createdAt:
  type: object
  ...

In my situation, I had references to outdated objects that were no longer available. Double check for any typing errors as well.

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

The declaration file for the 'react' module could not be located

I was exploring Microsoft's guide on TypeScript combined with React and Redux. After executing the command: npm install -S redux react-redux @types/react-redux I encountered an error when running npm run start: Type error: Could not find a decla ...

Ensuring accurate date formatting of API responses in TypeScript

My REST API returns data in the format shown below:- {"id": 1, "name": "New event", "date": "2020-11-14T18:02:00"} In my React frontend app, I have an interface like this:- export interface MyEvent { id ...

Angular 2: Streamlining user interface connections with extensive data rows

My challenge lies in displaying a list of items stored in an array[] when the user clicks on a tab. The data set contains around 10k rows, which is quite large, and currently takes approximately 2 to 3 seconds to render on the UI after the click event. I a ...

Can TestCafe be used to simulate pressing the key combination (Ctrl + +)?

I've been having a tough time trying to use the key combination specified in the title (Ctrl + +). So far, this is what I've attempted: 'ctrl+\+' 'ctrl+\\+' Does TestCafe even support this key combination? T ...

I am developing a JWT authentication and authorization service for my Angular application. However, I am running into issues when trying to implement observables

I have created a user class and required interfaces as outlined below: user.ts import { Role } from '../auth/auth.enum' export interface IUser { _id: string email: string name: IName picture: string role: Role | string userStatus: b ...

What is the best way to activate an input field in react-select?

Currently, I am working on a dropdown feature using react-select and have encountered some issues that need to be addressed: 1) The input field should be focused in just one click (currently it requires 2 clicks). 2) When the dropdown is opened and a cha ...

The useEffect hook in React is signaling a missing dependency issue

Any tips on how to resolve warnings such as this one src\components\pages\badge\BadgeScreen.tsx Line 87:6: React Hook useEffect has a missing dependency: 'loadData'. Either include it or remove the dependency array react-hoo ...

Tips for effectively utilizing TypeORM transactions

I'm encountering an issue with transactions in TypeORM. Here's a snippet of the code causing me trouble: const someFunction = async () => { try { await this.entityManager.transaction(async (manager) => { //some opera ...

Exploring the effectiveness of testing Svelte components

Looking to test a component that utilizes a third-party module without mocking the imported components? Check out this example: // test.spec.ts import Component from "Component"; describe('Component', () => { test('shoul ...

What could be causing TypeScript to throw errors regarding the initialState type when defining redux slices with createSlice in reduxToolkit, despite it being the correct type specified?

Here is my implementation of the createSlice() function: import { createSlice, PayloadAction } from "@reduxjs/toolkit"; type TransferDeckModeType = "pipetting" | "evaluation" | "editing"; var initialState: Transfer ...

Could someone provide a detailed explanation of exhaustMap in the context of Angular using rxjs?

import { HttpHandler, HttpInterceptor, HttpParams, HttpRequest, } from '@angular/common/http'; import { Injectable } from '@core/services/auth.service'; import { exhaustMap, take } from 'rxjs/operators'; import { Authe ...

Component in Next.js fetching data from an external API

I am attempting to generate cards dynamically with content fetched from an API. Unfortunately, I have been unsuccessful in finding a method that works during website rendering. My goal is to pass the "packages" as properties to the component within the div ...

Capture individual frames from angular video footage

Trying to extract frames from a video using Angular has been quite challenging for me. While browsing through Stack Overflow, I came across this helpful post here. I attempted to implement the first solution suggested in the post, but unfortunately, I was ...

Refresh the Angular component following updates to the store

Working with NGRX/Redux for the first time, I am puzzled by why my component fails to update after adding a new item to an array in the store. Within my main component, these properties are defined: productLines$: Observable<ProductionLine[]>; produ ...

Unable to establish breakpoints in TypeScript within VS Code

I seem to be facing an issue while trying to set breakpoints in my TypeScript nodejs app using Visual Studio Code. Despite following the guidelines provided on the Visual Studio Code website, I have not been able to achieve success. Below is the content o ...

Leveraging Nextjs Link alongside MUI Link or MUI Button within a different functional component (varieties)

Currently in my development setup, I am utilizing Next.js (10.2) and Material-UI (MUI) with Typescript. In the process, I have implemented a custom Link component: Link.tsx (/components) [...] On top of that, I have created another iteration which functi ...

Show the user's chosen name in place of their actual identity during a chat

I'm facing an issue where I want to show the user's friendly name in a conversation, but it looks like the Message resource only returns the identity string as the message author. I attempted to retrieve the conversation participants, generate a ...

The TypeScript extension of a type from an npm package is malfunctioning

I am utilizing the ws package to handle WebSockets in my Node.js project. I aim to include a unique isHealthy attribute to the WebSocket class. The approach I have taken is as follows: // globals.d.ts import "ws" declare module "ws" { ...

To properly display a URL on a webpage using Angular, it is necessary to decode

After my console.log in Angular 5 service call to the component, I can see the correct data URL being displayed http://localhost:4200/inquiry?UserID=645 However, when it is inside an Angular for loop in the HTML template, it displays http://localhost:42 ...

Invoke a function and assign it to an export variable

I have a query regarding a file containing an export constant that is utilized to construct a navigation bar in CoreUI. However, I am exploring methods to generate dynamic JSON data within other Components or the same file and then inject it into the exp ...