Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,18 @@ extension TypeSyntax {
}

return .primitive(primitive, schema: "\(raw: primitive.schema)()")
case .memberType(let memberType):
// Handle qualified type names like Weather.Condition
let fullTypeName = memberType.trimmed.description
return .schemable(
fullTypeName,
schema: "\(raw: fullTypeName).schema"
)
case .implicitlyUnwrappedOptionalType(let implicitlyUnwrappedOptionalType):
return implicitlyUnwrappedOptionalType.wrappedType.typeInformation()
case .optionalType(let optionalType): return optionalType.wrappedType.typeInformation()
case .someOrAnyType(let someOrAnyType): return someOrAnyType.constraint.typeInformation()
case .attributedType, .classRestrictionType, .compositionType, .functionType, .memberType,
case .attributedType, .classRestrictionType, .compositionType, .functionType,
.metatypeType, .missingType, .namedOpaqueReturnType, .packElementType, .packExpansionType,
.suppressedType, .tupleType:
return .notSupported
Expand Down
31 changes: 31 additions & 0 deletions Tests/JSONSchemaIntegrationTests/NestedTypeIntegrationTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import JSONSchemaBuilder
import Testing

// Test that @Schemable works with qualified type names (MemberType syntax)
enum Weather {
@Schemable
enum Condition: String, Sendable {
case sunny
case rainy
}
}

@Schemable
struct Forecast: Sendable {
let date: String
let condition: Weather.Condition
}

struct MemberTypeTests {
@Test func qualifiedTypeNameSupport() throws {
// Verify that properties with qualified type names like Weather.Condition
// are properly included in schema generation
let json = """
{"date":"2025-10-30","condition":"rainy"}
"""
let result = try Forecast.schema.parse(instance: json)
#expect(result.value != nil)
#expect(result.value?.date == "2025-10-30")
#expect(result.value?.condition == .rainy)
}
}
Loading