Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): implement {} insterd of unknown for blank schema interface #1219

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

soartec-lab
Copy link
Member

Status

READY/

Description

fix #1207

If the definition schema is blank object and output.override.use TypeOver Interfaces is false, the generated definition is incorrect.
I fixed it to create {} when using interface.

Before

export interface DbNotificationID unknown

After

export interface DbNotificationID = {}

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. prepared openapi woth blank object
openapi: 3.0.3
info:
  description: test
  title: test
  version: test
paths:
  /ping:
    get:
      summary: test
      responses:
        '200':
          description: ok
components:
  schemas:
    DbNotificationID: {}
  1. execute orval
  2. check generated definition is valid

@melloware melloware merged commit 97552e4 into orval-labs:master Feb 13, 2024
2 checks passed
@melloware melloware added this to the 6.25.0 milestone Feb 13, 2024
@melloware melloware added the bug Something isn't working label Feb 13, 2024
@melloware
Copy link
Collaborator

@soartec-lab this broke React Query in 6.25.0 I now get these TypeScript errors.

  Line 26:40:  Don't use `{}` as a type. `{}` actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want `object` instead.
- If you want a type meaning "any value", you probably want `unknown` instead.
- ```

in 6.24.0 code was this

```js
export interface FilterConstraint {
	/** Filter match mode e.g. equals, notEquals, contains, notContains, gt, gte, lt, lte */
	matchMode?: string;
	/** Value to filter this column by */
	value?: unknown;
}

in 6.25.0 its this...

/**
 * Value to filter this column by
 */
export type FilterConstraintValue = {};

export interface FilterConstraint {
	/** Filter match mode e.g. equals, notEquals, contains, notContains, gt, gte, lt, lte */
	matchMode?: string;
	/** Value to filter this column by */
	value?: FilterConstraintValue;
}

Which is now broken.

soartec-lab added a commit to soartec-lab/orval that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid typescript generation for empty schema
2 participants