|
22 | 22 |
|
23 | 23 | public class Sttp4CodegenTest { |
24 | 24 |
|
25 | | - @Test |
26 | | - public void verifyApiKeyLocations() throws IOException { |
27 | | - File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
28 | | - output.deleteOnExit(); |
29 | | - String outputPath = output.getAbsolutePath().replace('\\', '/'); |
30 | | - |
31 | | - OpenAPI openAPI = new OpenAPIParser() |
32 | | - .readLocation("src/test/resources/bugs/issue_13474.json", null, new ParseOptions()).getOpenAPI(); |
33 | | - |
34 | | - ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
35 | | - codegen.setOutputDir(output.getAbsolutePath()); |
36 | | - codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); |
37 | | - |
38 | | - ClientOptInput input = new ClientOptInput(); |
39 | | - input.openAPI(openAPI); |
40 | | - input.config(codegen); |
41 | | - |
42 | | - DefaultGenerator generator = new DefaultGenerator(); |
43 | | - |
44 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
45 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
46 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
47 | | - generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); |
48 | | - generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
49 | | - generator.opts(input).generate(); |
50 | | - |
51 | | - Path path = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala"); |
52 | | - assertFileContains(path, ".method(Method.GET, uri\"$baseUrl/entities/?api_key=${apiKeyQuery}\")\n"); |
53 | | - assertFileContains(path, ".header(\"X-Api-Key\", apiKeyHeader)"); |
54 | | - assertFileContains(path, ".cookie(\"apikey\", apiKeyCookie)"); |
55 | | - } |
56 | | - |
57 | | - @Test |
58 | | - public void verifyOneOfSupportWithCirce() throws IOException { |
59 | | - File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
60 | | - output.deleteOnExit(); |
61 | | - String outputPath = output.getAbsolutePath().replace('\\', '/'); |
62 | | - |
63 | | - OpenAPI openAPI = new OpenAPIParser() |
64 | | - .readLocation("src/test/resources/3_0/scala/sttp4-oneOf.yaml", null, new ParseOptions()).getOpenAPI(); |
65 | | - |
66 | | - ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
67 | | - codegen.setOutputDir(output.getAbsolutePath()); |
68 | | - codegen.additionalProperties().put("jsonLibrary", "circe"); |
69 | | - |
70 | | - ClientOptInput input = new ClientOptInput(); |
71 | | - input.openAPI(openAPI); |
72 | | - input.config(codegen); |
73 | | - |
74 | | - DefaultGenerator generator = new DefaultGenerator(); |
75 | | - |
76 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
77 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
78 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
79 | | - generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
80 | | - generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
81 | | - generator.opts(input).generate(); |
82 | | - |
83 | | - // Test oneOf without discriminator generates sealed trait with semiauto |
84 | | - Path petPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Pet.scala"); |
85 | | - assertFileContains(petPath, "sealed trait Pet"); |
86 | | - assertFileContains(petPath, "object Pet {"); |
87 | | - assertFileContains(petPath, "import io.circe.generic.semiauto._"); |
88 | | - assertFileContains(petPath, "// oneOf without discriminator - using semiauto derivation"); |
89 | | - assertFileContains(petPath, "implicit val encoder: Encoder[Pet] = deriveEncoder"); |
90 | | - assertFileContains(petPath, "implicit val decoder: Decoder[Pet] = deriveDecoder"); |
91 | | - |
92 | | - // Test oneOf with discriminator uses semiauto with Configuration |
93 | | - Path animalPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Animal.scala"); |
94 | | - assertFileContains(animalPath, "sealed trait Animal"); |
95 | | - assertFileContains(animalPath, "object Animal {"); |
96 | | - assertFileContains(animalPath, "import io.circe.generic.extras.semiauto._"); |
97 | | - assertFileContains(animalPath, "// oneOf with discriminator - using semiauto derivation with Configuration"); |
98 | | - assertFileContains(animalPath, |
99 | | - "private implicit val config: Configuration = Configuration.default.withDiscriminator(\"petType\")"); |
100 | | - assertFileContains(animalPath, "implicit val encoder: Encoder[Animal] = deriveConfiguredEncoder"); |
101 | | - assertFileContains(animalPath, "implicit val decoder: Decoder[Animal] = deriveConfiguredDecoder"); |
102 | | - |
103 | | - // Test oneOf with discriminator mapping |
104 | | - Path vehiclePath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Vehicle.scala"); |
105 | | - assertFileContains(vehiclePath, "sealed trait Vehicle"); |
106 | | - assertFileContains(vehiclePath, "object Vehicle {"); |
107 | | - assertFileContains(vehiclePath, "// oneOf with discriminator - using semiauto derivation with Configuration"); |
108 | | - assertFileContains(vehiclePath, |
109 | | - "private implicit val config: Configuration = Configuration.default.withDiscriminator(\"vehicleType\")"); |
110 | | - assertFileContains(vehiclePath, "\"Car\" => \"car\""); |
111 | | - assertFileContains(vehiclePath, "\"Truck\" => \"truck\""); |
112 | | - |
113 | | - // Verify regular models are still case classes |
114 | | - Path dogPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Dog.scala"); |
115 | | - assertFileContains(dogPath, "case class Dog("); |
116 | | - assertFileContains(dogPath, "name: String"); |
117 | | - assertFileContains(dogPath, "breed: String"); |
118 | | - } |
119 | | - |
120 | | - @Test |
121 | | - public void verifyOneOfSupportWithJson4s() throws IOException { |
122 | | - File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
123 | | - output.deleteOnExit(); |
124 | | - String outputPath = output.getAbsolutePath().replace('\\', '/'); |
125 | | - |
126 | | - OpenAPI openAPI = new OpenAPIParser() |
127 | | - .readLocation("src/test/resources/3_0/scala/sttp4-oneOf.yaml", null, new ParseOptions()).getOpenAPI(); |
128 | | - |
129 | | - ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
130 | | - codegen.setOutputDir(output.getAbsolutePath()); |
131 | | - codegen.additionalProperties().put("jsonLibrary", "json4s"); |
132 | | - |
133 | | - ClientOptInput input = new ClientOptInput(); |
134 | | - input.openAPI(openAPI); |
135 | | - input.config(codegen); |
136 | | - |
137 | | - DefaultGenerator generator = new DefaultGenerator(); |
138 | | - |
139 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
140 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
141 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
142 | | - generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
143 | | - generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
144 | | - generator.opts(input).generate(); |
145 | | - |
146 | | - // Test oneOf without discriminator generates sealed trait with json4s |
147 | | - Path petPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Pet.scala"); |
148 | | - assertFileContains(petPath, "sealed trait Pet"); |
149 | | - assertFileContains(petPath, "object Pet {"); |
150 | | - assertFileContains(petPath, "import org.json4s._"); |
151 | | - assertFileContains(petPath, "// oneOf without discriminator - json4s custom serializer"); |
152 | | - assertFileContains(petPath, "implicit object PetSerializer extends Serializer[Pet]"); |
153 | | - assertFileContains(petPath, "Extraction.extract[Dog](json)"); |
154 | | - assertFileContains(petPath, "Extraction.extract[Cat](json)"); |
155 | | - |
156 | | - // Test oneOf with discriminator |
157 | | - Path animalPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Animal.scala"); |
158 | | - assertFileContains(animalPath, "sealed trait Animal"); |
159 | | - assertFileContains(animalPath, "// oneOf with discriminator"); |
160 | | - assertFileContains(animalPath, "petType"); |
161 | | - } |
162 | | - |
163 | | - @Test |
164 | | - public void verifyOneOfWithEmptyMembers() throws IOException { |
165 | | - File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
166 | | - output.deleteOnExit(); |
167 | | - String outputPath = output.getAbsolutePath().replace('\\', '/'); |
168 | | - |
169 | | - OpenAPI openAPI = new OpenAPIParser() |
170 | | - .readLocation("src/test/resources/3_0/scala/sttp4-oneOf-empty-members.yaml", null, new ParseOptions()) |
171 | | - .getOpenAPI(); |
172 | | - |
173 | | - ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
174 | | - codegen.setOutputDir(output.getAbsolutePath()); |
175 | | - codegen.additionalProperties().put("jsonLibrary", "circe"); |
176 | | - |
177 | | - ClientOptInput input = new ClientOptInput(); |
178 | | - input.openAPI(openAPI); |
179 | | - input.config(codegen); |
180 | | - |
181 | | - DefaultGenerator generator = new DefaultGenerator(); |
182 | | - |
183 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
184 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
185 | | - generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
186 | | - generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
187 | | - generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
188 | | - generator.opts(input).generate(); |
189 | | - |
190 | | - // Test sealed trait is generated correctly |
191 | | - Path eventPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Event.scala"); |
192 | | - assertFileContains(eventPath, "sealed trait Event"); |
193 | | - |
194 | | - // Test empty case classes (no properties except discriminator which was |
195 | | - // removed) |
196 | | - assertFileContains(eventPath, "case class ClickEvent(\n) extends Event"); |
197 | | - assertFileContains(eventPath, "case class ViewEvent(\n) extends Event"); |
198 | | - |
199 | | - // Test case class with properties (PurchaseEvent has amount) |
200 | | - assertFileContains(eventPath, "case class PurchaseEvent("); |
201 | | - assertFileContains(eventPath, "amount: Double"); |
202 | | - |
203 | | - // Verify discriminator is configured |
204 | | - assertFileContains(eventPath, "Configuration.default.withDiscriminator(\"eventType\")"); |
205 | | - |
206 | | - // Verify the discriminator property was removed from inline members |
207 | | - // ClickEvent and ViewEvent should have NO properties at all |
208 | | - assertFileContains(eventPath, "case class ClickEvent(\n) extends Event"); |
209 | | - assertFileContains(eventPath, "case class ViewEvent(\n) extends Event"); |
210 | | - } |
| 25 | + @Test |
| 26 | + public void verifyApiKeyLocations() throws IOException { |
| 27 | + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
| 28 | + output.deleteOnExit(); |
| 29 | + String outputPath = output.getAbsolutePath().replace('\\', '/'); |
| 30 | + |
| 31 | + OpenAPI openAPI = new OpenAPIParser() |
| 32 | + .readLocation("src/test/resources/bugs/issue_13474.json", null, new ParseOptions()).getOpenAPI(); |
| 33 | + |
| 34 | + ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
| 35 | + codegen.setOutputDir(output.getAbsolutePath()); |
| 36 | + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); |
| 37 | + |
| 38 | + ClientOptInput input = new ClientOptInput(); |
| 39 | + input.openAPI(openAPI); |
| 40 | + input.config(codegen); |
| 41 | + |
| 42 | + DefaultGenerator generator = new DefaultGenerator(); |
| 43 | + |
| 44 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
| 45 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
| 46 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
| 47 | + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); |
| 48 | + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
| 49 | + generator.opts(input).generate(); |
| 50 | + |
| 51 | + Path path = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala"); |
| 52 | + assertFileContains(path, ".method(Method.GET, uri\"$baseUrl/entities/?api_key=${apiKeyQuery}\")\n"); |
| 53 | + assertFileContains(path, ".header(\"X-Api-Key\", apiKeyHeader)"); |
| 54 | + assertFileContains(path, ".cookie(\"apikey\", apiKeyCookie)"); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void verifyOneOfSupportWithCirce() throws IOException { |
| 59 | + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
| 60 | + output.deleteOnExit(); |
| 61 | + String outputPath = output.getAbsolutePath().replace('\\', '/'); |
| 62 | + |
| 63 | + OpenAPI openAPI = new OpenAPIParser() |
| 64 | + .readLocation("src/test/resources/3_0/scala/sttp4-oneOf.yaml", null, new ParseOptions()).getOpenAPI(); |
| 65 | + |
| 66 | + ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
| 67 | + codegen.setOutputDir(output.getAbsolutePath()); |
| 68 | + codegen.additionalProperties().put("jsonLibrary", "circe"); |
| 69 | + |
| 70 | + ClientOptInput input = new ClientOptInput(); |
| 71 | + input.openAPI(openAPI); |
| 72 | + input.config(codegen); |
| 73 | + |
| 74 | + DefaultGenerator generator = new DefaultGenerator(); |
| 75 | + |
| 76 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
| 77 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
| 78 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
| 79 | + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
| 80 | + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
| 81 | + generator.opts(input).generate(); |
| 82 | + |
| 83 | + // Test oneOf without discriminator generates sealed trait with semiauto |
| 84 | + Path petPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Pet.scala"); |
| 85 | + assertFileContains(petPath, "sealed trait Pet"); |
| 86 | + assertFileContains(petPath, "object Pet {"); |
| 87 | + assertFileContains(petPath, "import io.circe.generic.semiauto._"); |
| 88 | + assertFileContains(petPath, "// oneOf without discriminator - using semiauto derivation"); |
| 89 | + assertFileContains(petPath, "implicit val encoder: Encoder[Pet] = deriveEncoder"); |
| 90 | + assertFileContains(petPath, "implicit val decoder: Decoder[Pet] = deriveDecoder"); |
| 91 | + |
| 92 | + // Test oneOf with discriminator uses semiauto with Configuration |
| 93 | + Path animalPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Animal.scala"); |
| 94 | + assertFileContains(animalPath, "sealed trait Animal"); |
| 95 | + assertFileContains(animalPath, "object Animal {"); |
| 96 | + assertFileContains(animalPath, "import io.circe.generic.extras.semiauto._"); |
| 97 | + assertFileContains(animalPath, "// oneOf with discriminator - using semiauto derivation with Configuration"); |
| 98 | + assertFileContains(animalPath, |
| 99 | + "private implicit val config: Configuration = Configuration.default.withDiscriminator(\"petType\")"); |
| 100 | + assertFileContains(animalPath, "implicit val encoder: Encoder[Animal] = deriveConfiguredEncoder"); |
| 101 | + assertFileContains(animalPath, "implicit val decoder: Decoder[Animal] = deriveConfiguredDecoder"); |
| 102 | + |
| 103 | + // Test oneOf with discriminator mapping |
| 104 | + Path vehiclePath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Vehicle.scala"); |
| 105 | + assertFileContains(vehiclePath, "sealed trait Vehicle"); |
| 106 | + assertFileContains(vehiclePath, "object Vehicle {"); |
| 107 | + assertFileContains(vehiclePath, "// oneOf with discriminator - using semiauto derivation with Configuration"); |
| 108 | + assertFileContains(vehiclePath, |
| 109 | + "private implicit val config: Configuration = Configuration.default.withDiscriminator(\"vehicleType\")"); |
| 110 | + assertFileContains(vehiclePath, "\"Car\" => \"car\""); |
| 111 | + assertFileContains(vehiclePath, "\"Truck\" => \"truck\""); |
| 112 | + |
| 113 | + // Verify regular models are still case classes |
| 114 | + Path dogPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Dog.scala"); |
| 115 | + assertFileContains(dogPath, "case class Dog("); |
| 116 | + assertFileContains(dogPath, "name: String"); |
| 117 | + assertFileContains(dogPath, "breed: String"); |
| 118 | + } |
| 119 | + |
| 120 | + @Test |
| 121 | + public void verifyOneOfSupportWithJson4s() throws IOException { |
| 122 | + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
| 123 | + output.deleteOnExit(); |
| 124 | + String outputPath = output.getAbsolutePath().replace('\\', '/'); |
| 125 | + |
| 126 | + OpenAPI openAPI = new OpenAPIParser() |
| 127 | + .readLocation("src/test/resources/3_0/scala/sttp4-oneOf.yaml", null, new ParseOptions()).getOpenAPI(); |
| 128 | + |
| 129 | + ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
| 130 | + codegen.setOutputDir(output.getAbsolutePath()); |
| 131 | + codegen.additionalProperties().put("jsonLibrary", "json4s"); |
| 132 | + |
| 133 | + ClientOptInput input = new ClientOptInput(); |
| 134 | + input.openAPI(openAPI); |
| 135 | + input.config(codegen); |
| 136 | + |
| 137 | + DefaultGenerator generator = new DefaultGenerator(); |
| 138 | + |
| 139 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
| 140 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
| 141 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
| 142 | + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
| 143 | + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
| 144 | + generator.opts(input).generate(); |
| 145 | + |
| 146 | + // Test oneOf without discriminator generates sealed trait with json4s |
| 147 | + Path petPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Pet.scala"); |
| 148 | + assertFileContains(petPath, "sealed trait Pet"); |
| 149 | + assertFileContains(petPath, "object Pet {"); |
| 150 | + assertFileContains(petPath, "import org.json4s._"); |
| 151 | + assertFileContains(petPath, "// oneOf without discriminator - json4s custom serializer"); |
| 152 | + assertFileContains(petPath, "implicit object PetSerializer extends Serializer[Pet]"); |
| 153 | + assertFileContains(petPath, "Extraction.extract[Dog](json)"); |
| 154 | + assertFileContains(petPath, "Extraction.extract[Cat](json)"); |
| 155 | + |
| 156 | + // Test oneOf with discriminator |
| 157 | + Path animalPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Animal.scala"); |
| 158 | + assertFileContains(animalPath, "sealed trait Animal"); |
| 159 | + assertFileContains(animalPath, "// oneOf with discriminator"); |
| 160 | + assertFileContains(animalPath, "petType"); |
| 161 | + } |
| 162 | + |
| 163 | + @Test |
| 164 | + public void verifyOneOfWithEmptyMembers() throws IOException { |
| 165 | + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
| 166 | + output.deleteOnExit(); |
| 167 | + String outputPath = output.getAbsolutePath().replace('\\', '/'); |
| 168 | + |
| 169 | + OpenAPI openAPI = new OpenAPIParser() |
| 170 | + .readLocation("src/test/resources/3_0/scala/sttp4-oneOf-empty-members.yaml", null, new ParseOptions()) |
| 171 | + .getOpenAPI(); |
| 172 | + |
| 173 | + ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen(); |
| 174 | + codegen.setOutputDir(output.getAbsolutePath()); |
| 175 | + codegen.additionalProperties().put("jsonLibrary", "circe"); |
| 176 | + |
| 177 | + ClientOptInput input = new ClientOptInput(); |
| 178 | + input.openAPI(openAPI); |
| 179 | + input.config(codegen); |
| 180 | + |
| 181 | + DefaultGenerator generator = new DefaultGenerator(); |
| 182 | + |
| 183 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); |
| 184 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); |
| 185 | + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); |
| 186 | + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false"); |
| 187 | + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); |
| 188 | + generator.opts(input).generate(); |
| 189 | + |
| 190 | + // Test sealed trait is generated correctly |
| 191 | + Path eventPath = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/model/Event.scala"); |
| 192 | + assertFileContains(eventPath, "sealed trait Event"); |
| 193 | + |
| 194 | + // Test empty case classes (no properties except discriminator which was |
| 195 | + // removed) |
| 196 | + assertFileContains(eventPath, "case class ClickEvent(\n) extends Event"); |
| 197 | + assertFileContains(eventPath, "case class ViewEvent(\n) extends Event"); |
| 198 | + |
| 199 | + // Test case class with properties (PurchaseEvent has amount) |
| 200 | + assertFileContains(eventPath, "case class PurchaseEvent("); |
| 201 | + assertFileContains(eventPath, "amount: Double"); |
| 202 | + |
| 203 | + // Verify discriminator is configured |
| 204 | + assertFileContains(eventPath, "Configuration.default.withDiscriminator(\"eventType\")"); |
| 205 | + |
| 206 | + // Verify the discriminator property was removed from inline members |
| 207 | + // ClickEvent and ViewEvent should have NO properties at all |
| 208 | + assertFileContains(eventPath, "case class ClickEvent(\n) extends Event"); |
| 209 | + assertFileContains(eventPath, "case class ViewEvent(\n) extends Event"); |
| 210 | + } |
211 | 211 | } |
0 commit comments