|
17 | 17 |
|
18 | 18 | package org.openapitools.codegen.utils; |
19 | 19 |
|
20 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
21 | 20 | import com.fasterxml.jackson.databind.JsonNode; |
22 | 21 | import com.fasterxml.jackson.databind.ObjectMapper; |
23 | | -import io.swagger.util.Yaml; |
24 | 22 | import io.swagger.v3.core.util.AnnotationsUtils; |
25 | 23 | import io.swagger.v3.oas.models.OpenAPI; |
26 | 24 | import io.swagger.v3.oas.models.Operation; |
27 | 25 | import io.swagger.v3.oas.models.PathItem; |
28 | | -import io.swagger.v3.oas.models.SpecVersion; |
29 | 26 | import io.swagger.v3.oas.models.callbacks.Callback; |
30 | 27 | import io.swagger.v3.oas.models.headers.Header; |
31 | 28 | import io.swagger.v3.oas.models.media.*; |
@@ -565,7 +562,7 @@ public static boolean isMapSchema(Schema schema) { |
565 | 562 |
|
566 | 563 | // additionalProperties explicitly set to false |
567 | 564 | if ((schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) || |
568 | | - (schema.getAdditionalProperties() instanceof Schema && Boolean.FALSE.equals(((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue())) |
| 565 | + (schema.getAdditionalProperties() instanceof Schema && Boolean.FALSE.equals(((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue())) |
569 | 566 | ) { |
570 | 567 | return false; |
571 | 568 | } |
@@ -815,12 +812,12 @@ public static boolean isModelWithPropertiesOnly(Schema schema) { |
815 | 812 | (null != schema.getProperties() && !schema.getProperties().isEmpty()) && |
816 | 813 | // no additionalProperties is set |
817 | 814 | (schema.getAdditionalProperties() == null || |
818 | | - // additionalProperties is boolean and set to false |
819 | | - (schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()) || |
820 | | - // additionalProperties is a schema with its boolean value set to false |
821 | | - (schema.getAdditionalProperties() instanceof Schema && |
822 | | - ((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue() != null && |
823 | | - !((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue()) |
| 815 | + // additionalProperties is boolean and set to false |
| 816 | + (schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()) || |
| 817 | + // additionalProperties is a schema with its boolean value set to false |
| 818 | + (schema.getAdditionalProperties() instanceof Schema && |
| 819 | + ((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue() != null && |
| 820 | + !((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue()) |
824 | 821 | ); |
825 | 822 | } |
826 | 823 |
|
@@ -2271,88 +2268,6 @@ public static boolean isParent(Schema schema) { |
2271 | 2268 | return false; |
2272 | 2269 | } |
2273 | 2270 |
|
2274 | | - /** |
2275 | | - * copy all the fields from the origin schema to the destination schema. |
2276 | | - * @param schema original schema |
2277 | | - * @param dest the destination schema |
2278 | | - * @return dest |
2279 | | - */ |
2280 | | - |
2281 | | - public static Schema shallowCopy(Schema schema, Schema dest) { |
2282 | | - // cloneSchema does not work because it does conversions for some attributes (enums, default...) |
2283 | | - // the intermediate JSON can convert between integer and BigInteger for example. |
2284 | | - // so copy all the fields individually |
2285 | | - dest.setDefault(schema.getDefault()); |
2286 | | - dest.setName(schema.getName()); |
2287 | | - dest.setTitle(schema.getTitle()); |
2288 | | - dest.setMultipleOf(schema.getMultipleOf()); |
2289 | | - dest.setMaximum(schema.getMaximum()); |
2290 | | - dest.setExclusiveMaximum(schema.getExclusiveMaximum()); |
2291 | | - dest.setMinimum(schema.getMinimum()); |
2292 | | - dest.setExclusiveMinimum(schema.getExclusiveMinimum()); |
2293 | | - dest.setMaxLength(schema.getMaxLength()); |
2294 | | - dest.setPattern(schema.getPattern()); |
2295 | | - dest.setMaxItems(schema.getMaxItems()); |
2296 | | - dest.setMinItems(schema.getMinItems()); |
2297 | | - dest.setUnevaluatedItems(schema.getUnevaluatedItems()); |
2298 | | - dest.setMaxProperties(schema.getMaxProperties()); |
2299 | | - dest.setMinProperties(schema.getMinProperties()); |
2300 | | - dest.setRequired(schema.getRequired()); |
2301 | | - dest.setType(schema.getType()); |
2302 | | - dest.setNot(schema.getNot()); |
2303 | | - dest.setProperties(schema.getProperties()); |
2304 | | - dest.setDescription(schema.getDescription()); |
2305 | | - dest.setFormat(schema.getFormat()); |
2306 | | - dest.set$ref(schema.get$ref()); |
2307 | | - dest.setNullable(schema.getNullable()); |
2308 | | - dest.setReadOnly(schema.getReadOnly()); |
2309 | | - dest.setWriteOnly(schema.getWriteOnly()); |
2310 | | - dest.setExample(schema.getExample()); |
2311 | | - dest.setExternalDocs(schema.getExternalDocs()); |
2312 | | - dest.setDeprecated(schema.getDeprecated()); |
2313 | | - dest.setXml(schema.getXml()); |
2314 | | - dest.setExtensions(schema.getExtensions()); |
2315 | | - dest.setEnum(schema.getEnum()); |
2316 | | - dest.setDiscriminator(schema.getDiscriminator()); |
2317 | | - dest.setExampleSetFlag(schema.getExampleSetFlag()); |
2318 | | - dest.setPrefixItems(schema.getPrefixItems()); |
2319 | | - dest.setAllOf(schema.getAllOf()); |
2320 | | - dest.setAnyOf(schema.getAnyOf()); |
2321 | | - dest.setOneOf(schema.getOneOf()); |
2322 | | - dest.setItems(schema.getItems()); |
2323 | | - dest.setConst(schema.getConst()); |
2324 | | - dest.setSpecVersion(schema.getSpecVersion()); |
2325 | | - dest.setPatternProperties(schema.getPatternProperties()); |
2326 | | - dest.setExclusiveMaximumValue(schema.getExclusiveMaximumValue()); |
2327 | | - dest.setExclusiveMinimumValue(schema.getExclusiveMinimumValue()); |
2328 | | - dest.setContains(schema.getContains()); |
2329 | | - dest.set$id(schema.get$id()); |
2330 | | - dest.set$schema(schema.get$schema()); |
2331 | | - dest.set$anchor(schema.get$anchor()); |
2332 | | - dest.set$vocabulary(schema.get$vocabulary()); |
2333 | | - dest.set$dynamicAnchor(schema.get$dynamicAnchor()); |
2334 | | - dest.set$dynamicRef(schema.get$dynamicRef()); |
2335 | | - dest.setContentEncoding(schema.getContentEncoding()); |
2336 | | - dest.setContentMediaType(schema.getContentMediaType()); |
2337 | | - dest.setPropertyNames(schema.getPropertyNames()); |
2338 | | - dest.setUnevaluatedProperties(schema.getUnevaluatedProperties()); |
2339 | | - dest.setMaxContains(schema.getMaxContains()); |
2340 | | - dest.setMinContains(schema.getMinContains()); |
2341 | | - dest.setAdditionalItems(schema.getAdditionalItems()); |
2342 | | - dest.setUnevaluatedItems(schema.getUnevaluatedItems()); |
2343 | | - dest.setIf(schema.getIf()); |
2344 | | - dest.setElse(schema.getElse()); |
2345 | | - dest.setThen(schema.getThen()); |
2346 | | - dest.setDependentSchemas(schema.getDependentSchemas()); |
2347 | | - dest.setDependentRequired(schema.getDependentRequired()); |
2348 | | - dest.set$comment(schema.get$comment()); |
2349 | | - dest.setExamples(schema.getExamples()); |
2350 | | - dest.setBooleanSchemaValue(schema.getBooleanSchemaValue()); |
2351 | | - dest.setJsonSchema(schema.getJsonSchema()); |
2352 | | - dest.setJsonSchemaImpl(schema.getJsonSchemaImpl()); |
2353 | | - return dest; |
2354 | | - } |
2355 | | - |
2356 | 2271 | public static Schema cloneSchema(Schema schema, boolean openapi31) { |
2357 | 2272 | if (openapi31) { |
2358 | 2273 | return AnnotationsUtils.clone(schema, openapi31); |
@@ -2730,20 +2645,4 @@ public LinkedHashSet<String> build() { |
2730 | 2645 | } |
2731 | 2646 | } |
2732 | 2647 | } |
2733 | | - |
2734 | | - |
2735 | | - /* |
2736 | | - * Simplest dump of an openApi contract on the console. |
2737 | | - * |
2738 | | - * Only use for debugging. |
2739 | | - */ |
2740 | | - public static void dumpAsYaml(OpenAPI openAPI) { |
2741 | | - ObjectMapper mapper = Yaml.mapper(); |
2742 | | - try { |
2743 | | - String yaml = mapper.writeValueAsString(openAPI); |
2744 | | - System.out.println(yaml); |
2745 | | - } catch (JsonProcessingException e) { |
2746 | | - throw new RuntimeException(e); |
2747 | | - } |
2748 | | - } |
2749 | 2648 | } |
0 commit comments