Skip to content

Inline properties in AllOf that is not a ref #1628

Open
@StefanBRas

Description

@StefanBRas

What are the steps to reproduce this issue?

Given the spec

openapi: 3.0.3
info:
  title: test
  version: 0.1.0
paths: {}
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: string
    UserWithName:
      allOf:
        - $ref: '#/components/schemas/User'
        - type: object
          properties:
            name:
              type: string

I get

// user.ts
export interface User {
  id?: string;
}

// userWithNameAllOf.ts
export type UserWithNameAllOf = {
  name?: string;
};

// userWithName.ts
import type { User } from './user';
import type { UserWithNameAllOf } from './userWithNameAllOf';

export type UserWithName = User & UserWithNameAllOf;

Which is correctly, by the AllOf is kinda redundant.

What were you expecting to happen?

// user.ts
export interface User {
  id?: string;
}

export type UserWithNameAllOf = 

// userWithName.ts
import type { User } from './user';

export type UserWithName = User & {name?: string};

Which is equivalent, but nicer.

Any logs, error output, etc?

Any other comments?

I can see that some people might want to have it as a separate type, but the names quickly become long and ugly.

Maybe it should be a configuration option?

What versions are you using?

  System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 69.92 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  npmPackages:
    @tanstack/react-query: ^4.22.0 => 4.36.1 
    axios: ^1.7.4 => 1.7.7 
    orval: 7.1.0 => 7.1.0 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions