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: Correctly set type for false or 0 constants #1653

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

RinseV
Copy link
Contributor

@RinseV RinseV commented Oct 1, 2024

Status

READY

Description

Fixes #1647

I've expanded the const specification to include false and 0 constants. Before this change, the models were generated as:

export interface BooleanConst {
  value: true;
  valueFalse: boolean;
  valueNullable: BooleanConstValueNullable;
}

export interface IntegerConst {
  value: 1;
  valueNullable: IntegerConstValueNullable;
  valueZero: number;
}

After this change, the models are generated as:

export interface BooleanConst {
  value: true;
  valueFalse: false;
  valueNullable: BooleanConstValueNullable;
}

export interface IntegerConst {
  value: 1;
  valueNullable: IntegerConstValueNullable;
  valueZero: 0;
}

Related PRs

PR that introduced the problem

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

> git clone https://github.com/RinseV/orval.git
  1. Install dependencies & build the package
  2. Generate the default specification in the tests folder: yarn generate:default
  3. The generated models will have the correct literal types

@melloware melloware added this to the 7.2.0 milestone Oct 1, 2024
@melloware
Copy link
Collaborator

LGTM!

@melloware melloware merged commit 4692501 into orval-labs:master Oct 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create constant for false
2 participants