api-platform / create-client

Generate React or Vue.js-based Progressive Web Apps from an Hydra-enabled API. Also support React Native.
https://api-platform.com/docs/client-generator/
MIT License
374 stars 132 forks source link

fix js identifiers containing dashes #315

Closed 4rthem closed 2 years ago

4rthem commented 2 years ago
Q A
Branch? main
Tickets
License MIT
Doc PR

With the following entity:

resources:
  App\Entity\FooBar:
    shortName: foo-bar

typescript template outputs invalid JS:

type foo-bar {
   // ...
}

The following PR replaces dashes to underscores to produce valid JS code.

alanpoulain commented 2 years ago

Thanks for this PR. I've made a little change: when the field name is an invalid identifier, it will be quoted instead.