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.

Non unique enum names with `-` and `+` prefixes

See original GitHub issue

What are the steps to reproduce this issue?

  1. Add an enumeration with two values that vary only with the - and + prefixes:
        - in: query
          name: sort
          required: false
          description: >
            The property to sort on. Direction is ascending by default. To 
            indicate descending, prefix property with `-`
          schema:
            type: string
            enum:
              - date
              - -date

What happens?

Those special characters are ignored and the keys are identical:

  export const MyOperationSort = {
    date: '-date' as MyOperationSort,
    date: 'date' as MyOperationSort,
  };

What were you expecting to happen?

The special characters are escaped so that we can use the enumeration.

Any other comments?

This issue has been discovered while using the - and + convention to define the direction on a sorting parameter. It has been reported on the guideline owner too: https://github.com/belgif/rest-guide/issues/98

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
anymaniaxcommented, Nov 17, 2022

Hello @NimmLor, just added x-enumNames with the orval@6.11.0-alpha.4

1reaction
anymaniaxcommented, Nov 15, 2022

For the next release, I would like to give a flag to remove the parsing completely and also the possibility to parse it how you want

Read more comments on GitHub >

github_iconTop Results From Across the Web

CA1712: Do not prefix enum values with type name
Names of enumeration members are not prefixed with the type name because type information is expected to be provided by development tools.
Read more >
Duplicate ENUM names not handled correctly #197 - GitHub
If I understand correctly, you have raised the two issues here: 1: What if enum column name is same and different enum definitions...
Read more >
How to refer to different enum values which share a duplicate ...
The general way around this is to use prefixes which appear in most libraries like ... Then you can use the same names...
Read more >
10.2 — Unscoped enumerations - Learn C++
Unscoped enumerations are defined via the enum keyword. ... which are considered non-distinct from the types they are aliasing).
Read more >
Enum Type - Free Pascal wiki
An enumeration is defined by surrounding a non-empty comma-separated ... thus requiring users to always specify the type name as a prefix:.
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