Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

[Future] Improve parsing and print multiline enums #95

Open
aimmlegate opened this issue Jul 20, 2021 · 0 comments
Open

[Future] Improve parsing and print multiline enums #95

aimmlegate opened this issue Jul 20, 2021 · 0 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@aimmlegate
Copy link
Collaborator

aimmlegate commented Jul 20, 2021

For better readability and syntax simplicity better format multiline enums like this

v1 

Enum (
  | 'Aaa'
  | 'Bb'
  | 'Cccc'
  | 'BBB'
)

In the current implementation, we can support only this ugly style

v2

Enum (
  'Aaa' |
  'Bb' |
  'Cccc' |
  'BBB'
)

The problem consists of 2 parts

  1. Our parser cant parse multiline enums with separator | before the name. This can and should be fixed.
  2. Tinyspec cant parse enums with extra | properly, and add extra "".
Enum (
  | 'Aaa'
  | 'Bb'
  | 'Cccc'
  | 'BBB'
)

parsed to

    "Enum": {
      "enum": [
        "",
        "'Aaa'",
        "'Bb'",
        "'Cccc'",
        "'BBB'"
      ]
    }

and

Enum (
  'Aaa' |
  'Bb' |
  'Cccc' |
  'BBB' |
)

to this

    "Enum": {
      "enum": [
        "'Aaa'",
        "'Bb'",
        "'Cccc'",
        "'BBB'",
        ""
      ]
    }

So I see these options

✅1. Forget about it until we start to parse AST -> Open API on our own, and until then we print inline enums into v2
❌2. We fix our code to work with v1 format print everything into v1 and live with incorrect enums in Open API that tinyspec creates.

@aimmlegate aimmlegate added enhancement New feature or request question Further information is requested labels Jul 20, 2021
@aimmlegate aimmlegate changed the title Improve parsing and print multiline enums [Future] Improve parsing and print multiline enums Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant