question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of `allOf` generates an incomplete type

See original GitHub issue

What are the steps to reproduce this issue?

  1. Clone your repo
  2. yarn install and yarn build on the root
  3. cd samples/basic/ && yarn install and modify the petstore.yaml image
  4. Generate the model using yarn example

What happens?

The generated models look like this:

petBase.ts

/*
 * Generated by orval v5.5.3 🍺
 * Do not edit manually.
 * Swagger Petstore
 * OpenAPI spec version: 1.0.0
 */

export interface PetBase {
  id: number;
  name: string;
  tag?: string;
}

pet.ts

/*
 * Generated by orval v5.5.3 🍺
 * Do not edit manually.
 * Swagger Petstore
 * OpenAPI spec version: 1.0.0
 */
import type { PetBase } from './petBase';

export type Pet = PetBase;

What were you expecting to happen?

I would expect Pet to contain all fields of PetBase and the new color property like this:

pet.ts

/*
 * Generated by orval v5.5.3 🍺
 * Do not edit manually.
 * Swagger Petstore
 * OpenAPI spec version: 1.0.0
 */
import type { PetBase } from './petBase';

export interface Pet extends PetBase {
  color: string;
}
// OR
export type Pet = PetBase & { color: string; };

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jogelincommented, Aug 20, 2021

Hey @anymaniax, ok I understood my mistake, it was a syntax issue. I should specify it like:

    Pet:
      allOf:
        - $ref: '#/components/schemas/PetBase'
        - type: object <-- HERE
          required:
            - id
            - name
          properties:
            color:
              type: string

TBH, I would like to migrate from openapi generator. In openapi, the generation was working even with the wrong syntax:

export interface Pet {
  id: number;
  name: string;
  tag?: string;
  color: string;
}

I’ll fix my specs, thank you 😉

0reactions
anymaniaxcommented, Dec 2, 2021

Closing this issue since it’s normally fixed. Don’t hesitate if you have any problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] No more inheritance for components generated by ...
Hi all, I've filed #14172 to allow using $ref as parent in allOf with a new option called "openapi-normalizer". Please give it a...
Read more >
invalid use of incomplete type - c++ - Stack Overflow
The reason is that when instantiating a class template, all its declarations (not the definitions) of its member functions are instantiated ...
Read more >
4 Managing Oracle Objects
EXECUTE on an object type enables you to use the type to: Define a table. · UNDER enables you to create a subtype/subview...
Read more >
Using Incomplete (Forward) Declarations
An incomplete declaration is the keyword class or struct followed by the name of a class or structure type. It tells the.
Read more >
Class template - cppreference.com
a non-empty comma-separated list of the template parameters, each of which is either a non-type parameter, a type parameter, a template ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found