diff --git a/Sources/LexiconGenKit/Generator/Generator+Builders.swift b/Sources/LexiconGenKit/Generator/Generator+Builders.swift index 9f71ca5..cf1dbb3 100644 --- a/Sources/LexiconGenKit/Generator/Generator+Builders.swift +++ b/Sources/LexiconGenKit/Generator/Generator+Builders.swift @@ -80,6 +80,7 @@ public extension Generator { if let parameters = method.parameters { try objectSyntax( name: "Parameters", + modifiers: ["public"], inheritances: ["XRPCRequestParametersConvertible"], object: parameters ) { @@ -111,6 +112,7 @@ public extension Generator { case .object(let object): try objectSyntax( name: "Input", + modifiers: ["public"], inheritances: ["Encodable"], object: object ) @@ -124,6 +126,7 @@ public extension Generator { case .object(let object): try objectSyntax( name: "Output", + modifiers: ["public"], inheritances: ["Decodable", "Hashable"], object: object ) @@ -175,13 +178,15 @@ public extension Generator { @MemberBlockItemListBuilder static func objectSyntax( name: String, + modifiers: [String] = [], inheritances: [String] = [], object: LexiconObjectSchema, @MemberBlockItemListBuilder additionalBody: () throws -> MemberBlockItemListSyntax = { MemberBlockItemListSyntax([]) } ) throws -> MemberBlockItemListSyntax { + let modifier = modifiers.isEmpty ? "" : modifiers.joined(separator: " ") + " " let inherit = inheritances.isEmpty ? "" : ": " + inheritances.joined(separator: ", ") - try StructDeclSyntax("public struct \(raw: name)\(raw: inherit)") { + try StructDeclSyntax("\(raw: modifier)struct \(raw: name)\(raw: inherit)") { try Generator.objectPropertiesSyntax(object.properties, required: object.required) Generator.objectInitializerSyntax(object.properties, required: object.required) diff --git a/Tests/LexiconGenKitTests/Generator/Generator+BuildersTests.swift b/Tests/LexiconGenKitTests/Generator/Generator+BuildersTests.swift index dd6cf9b..95e7440 100644 --- a/Tests/LexiconGenKitTests/Generator/Generator+BuildersTests.swift +++ b/Tests/LexiconGenKitTests/Generator/Generator+BuildersTests.swift @@ -183,7 +183,7 @@ final class GeneratorBuildersTests: XCTestCase { ) ).formatted().description, """ - public struct Foo: UnionCodable, Hashable { + struct Foo: UnionCodable, Hashable { @Indirect public var optionalValue: String? @Indirect @@ -216,7 +216,7 @@ final class GeneratorBuildersTests: XCTestCase { ) ).formatted().description, """ - public struct Foo: UnionCodable, Hashable { + struct Foo: UnionCodable, Hashable { @Indirect public var optionalValue: String? @Indirect @@ -408,7 +408,7 @@ final class GeneratorBuildersTests: XCTestCase { } ).formatted().description, """ - public struct Object: Protocol1, Protocol2 { + struct Object: Protocol1, Protocol2 { @Indirect public var bar: Int? @Indirect