|
11 | 11 | import java.util.Map;
|
12 | 12 | import java.util.Set;
|
13 | 13 | import java.util.function.BiConsumer;
|
| 14 | +import java.util.function.Consumer; |
14 | 15 | import java.util.function.Function;
|
15 | 16 | import java.util.stream.Collectors;
|
16 | 17 | import java.util.stream.Stream;
|
@@ -187,17 +188,64 @@ void postProcessOpenAPI()
|
187 | 188 | //
|
188 | 189 | {
|
189 | 190 | dropSchemas("Geo(.*)View(.*)");
|
| 191 | + dropSchemas("LatLon(.*)"); |
190 | 192 | ((ComposedSchema) openAPI.getComponents().getSchemas().get("ViewProperties"))
|
191 | 193 | .getOneOf()
|
192 | 194 | .removeIf(schema -> schema.get$ref().endsWith("GeoViewProperties"));
|
193 | 195 | }
|
194 | 196 |
|
195 | 197 | //
|
196 |
| - // Drop supports for Templates, Stack |
| 198 | + // Templates, Stack API |
197 | 199 | //
|
198 | 200 | {
|
199 |
| - dropSchemas("Stack(.*)|Template(.*)|LatLon(.*)"); |
200 |
| - dropPaths("/stacks(.*)|/templates(.*)"); |
| 201 | + // Fix naming for ViewLink and ViewsLink schema |
| 202 | + { |
| 203 | + Schema viewSchema = openAPI.getComponents().getSchemas().get("View"); |
| 204 | + Schema links = (Schema) viewSchema.getProperties().get("links"); |
| 205 | + ((Schema) links.getProperties().get("self")).setTitle("ViewLinks"); |
| 206 | + |
| 207 | + Schema viewsSchema = openAPI.getComponents().getSchemas().get("Views"); |
| 208 | + Schema viewsSchemaLinks = (Schema) viewsSchema.getProperties().get("links"); |
| 209 | + ((Schema) viewsSchemaLinks.getProperties().get("self")).setTitle("ViewLinks"); |
| 210 | + } |
| 211 | + |
| 212 | + // Fix naming for 'new' and 'old' property of TemplateSummary.diff |
| 213 | + { |
| 214 | + Schema schema = openAPI.getComponents().getSchemas().get("TemplateSummary"); |
| 215 | + ObjectSchema diff = (ObjectSchema) schema.getProperties().get("diff"); |
| 216 | + for (Map.Entry<String, Schema> entry : diff.getProperties().entrySet()) |
| 217 | + { |
| 218 | + String path = entry.getKey(); |
| 219 | + ArraySchema pathSchema = (ArraySchema) entry.getValue(); |
| 220 | + Schema newSchema = (Schema) pathSchema.getItems().getProperties().get("new"); |
| 221 | + if (newSchema != null && newSchema.get$ref() == null) |
| 222 | + { |
| 223 | + newSchema.setTitle("TemplateSummary_Diff_" + path + "_new_old"); |
| 224 | + } |
| 225 | + } |
| 226 | + } |
| 227 | + |
| 228 | + // Fix schema name for UpdateStack.additionalResources |
| 229 | + { |
| 230 | + Schema stackPatch = openAPI.getPaths() |
| 231 | + .get("/stacks/{stack_id}") |
| 232 | + .getPatch() |
| 233 | + .getRequestBody() |
| 234 | + .getContent() |
| 235 | + .get("application/json") |
| 236 | + .getSchema(); |
| 237 | + Schema additionalResources = ((ArraySchema) stackPatch.getProperties().get("additionalResources")) |
| 238 | + .getItems(); |
| 239 | + additionalResources.setTitle("PatchStackRequest_additionalResources"); |
| 240 | + } |
| 241 | + |
| 242 | + // |
| 243 | + // Drop if not supported |
| 244 | + // |
| 245 | + if (!generator.supportsStacksTemplates()) |
| 246 | + { |
| 247 | + dropPaths("/stacks(.*)|/templates(.*)"); |
| 248 | + } |
201 | 249 | }
|
202 | 250 |
|
203 | 251 | //
|
@@ -304,6 +352,24 @@ void postProcessOpenAPI()
|
304 | 352 | parameter.setDescription(description.trim());
|
305 | 353 | }
|
306 | 354 | });
|
| 355 | + for (PathItem path : openAPI.getPaths().values()) |
| 356 | + { |
| 357 | + for (Operation operation : path.readOperations()) |
| 358 | + { |
| 359 | + List<Parameter> parameters = operation.getParameters(); |
| 360 | + if (parameters != null) |
| 361 | + { |
| 362 | + for (Parameter parameter : parameters) |
| 363 | + { |
| 364 | + String description = parameter.getDescription(); |
| 365 | + if (description != null) |
| 366 | + { |
| 367 | + parameter.setDescription(description.trim()); |
| 368 | + } |
| 369 | + } |
| 370 | + } |
| 371 | + } |
| 372 | + } |
307 | 373 | }
|
308 | 374 |
|
309 | 375 | public void postProcessModel(final CodegenModel model, final Schema modelSchema, final Map<String, Schema> allDefinitions)
|
|
0 commit comments