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): distinguish the value when it is blank only in interface #1228

Conversation

soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Feb 19, 2024

Status

READY

Description

fix #1227

When I responded to #1219, it caused unintended destruction, so I revert #1219.
This issue occurs when the doesn't have type like a bellow:

NotDifinedType:
  properties:
    id:
      description: not defined type schema

And, the issue where the interface definition results in an error when interface is an blank schema is resolved by replacing the value only in the case of interfaces.

Related PRs

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
components:
  schemas:
    DbNotificationID: {}
  1. execute orval
  2. check generated definition is valid

@soartec-lab
Copy link
Member Author

This PR will be on hold until the discussion in #1227 is over. If you are in a hurry to fix the problem, I think this PR will help you.

@melloware
Copy link
Collaborator

@soartec-lab i added my openapi JSON an Orval config in the ticket if you want to verify.

@melloware melloware added this to the 6.26.0 milestone Feb 25, 2024
@melloware melloware added the bug Something isn't working label Feb 26, 2024
@@ -46,7 +46,10 @@ export const generateInterface = ({
scalar.type === 'object' &&
!context?.output.override?.useTypeOverInterfaces
) {
model += `export interface ${name} ${scalar.value}\n`;
// If `scalar.value` is 'unknown', replace it with `{}` to avoid type error
const blankIntefaceValue = scalar.value === 'unknown' ? '{}' : scalar.value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const blankIntefaceValue = scalar.value === 'unknown' ? '{}' : scalar.value;
const blankInterfaceValue = scalar.value === 'unknown' ? '{}' : scalar.value;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it

564dd8e

// If `scalar.value` is 'unknown', replace it with `{}` to avoid type error
const blankIntefaceValue = scalar.value === 'unknown' ? '{}' : scalar.value;

model += `export interface ${name} ${blankIntefaceValue}\n`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
model += `export interface ${name} ${blankIntefaceValue}\n`;
model += `export interface ${name} ${blankInterfaceValue}\n`;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it

564dd8e

@soartec-lab
Copy link
Member Author

@melloware
thanks. I missed typo so i'll fix it. And i need some more time for inspection.

@soartec-lab soartec-lab changed the title fix(core): unexecpect insterd blank schema so revert #1219 fix(core): distinguish the value when it is blank only in interface Mar 1, 2024
@soartec-lab soartec-lab requested a review from melloware March 1, 2024 00:08
@soartec-lab
Copy link
Member Author

@melloware
I have completed this PR, so please give me a review.

@melloware melloware merged commit dfa076a into orval-labs:master Mar 1, 2024
2 checks passed
@melloware
Copy link
Collaborator

Thanks!!

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.

React Query: Regression in 6.25.0 caused by #1207
2 participants