glideapps / glideapps/quicktype
Model generated for a directory is different from when it's generated from a single schema
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
Sample project: https://github.com/HiveHicks/QuicktypeTest
I've got a [directory](https://github.com/HiveHicks/QuicktypeTest/tree/master/events) that contains multiple schemas for events, and each of them references a [base event schema](https://github.com/HiveHicks/QuicktypeTest/blob/master/event.json) which is located one level up in the file structure.
When I generate a Swift model for a single event using [this script](https://github.com/HiveHicks/QuicktypeTest/blob/master/generateSingleEvent.sh), the [resulting model](https://github.com/HiveHicks/QuicktypeTest/blob/master/Event1.generated.swift) is clean and simple:
```swift
struct Event1 {
let id: String?
let name: String
let payload: [String: Any?]?
let type: TypeEnum?
}
```
But when I generate models for a directory using [this script](https://github.com/HiveHicks/QuicktypeTest/blob/master/generateAllEvents.sh), [they](https://github.com/HiveHicks/QuicktypeTest/blob/master/Events.generated.swift):
- become polluted with `schema`, `title` and `allOf` properties
- no `TypeEnum` is generated
- `payload` ends up only in one model (should be in both)
- `--struct-or-class class` doesn't work, structs are generated
```swift
struct Event1 {
let schema: String
let id: String
let title: String
let allOf: [Event1AllOf]
}
struct Event2 {
let schema: String
let id: String
let title: String
let allOf: [Event2AllOf]
}
```
Am I doing something wrong or it's supposed to work that way?
Contributor guide
Assessment
This issue has not been assessed yet.