-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Hi,
I have an enum that looks like the one below. The package correctly generates it as a schema and uses the $ref in the enclosing struct.
However, in the enclosing struct, the enum property is optional, so it should be marked as nullable in the OpenAPI specification — but that’s not the case.
Am I doing something wrong?
For comparison, the other optional properties in the struct (that are not $refs) are correctly marked as nullable.
Enum:
import SwiftOpenAPI
enum TestEnum: String, CaseIterable {
case testA = "TestA"
case testB = "TestB"
}
extension TestEnum: OpenAPIType {
static var openAPISchema: SchemaObject {
.enum(of: .string, cases: allCases.map { .string($0.rawValue) })
.with(\.description,
"""
- "TestA": Description for TestA.
- "TestB": Description for TestB.
""")
}
}Struct that uses it:
import Vapor
import VaporToOpenAPI
struct TestStruct: Content {
var boolProp: Bool?
var enumProp: TestEnum?
}Relevant OAS output:
"boolProp": {
"type": "boolean",
"nullable": true
},
"enumProp": {
"$ref": "#/components/schemas/TestStruct"
},
dankinsoid
Metadata
Metadata
Assignees
Labels
No labels