|
25 | 25 | import io.swagger.v3.oas.models.OpenAPI; |
26 | 26 | import io.swagger.v3.oas.models.Operation; |
27 | 27 | import io.swagger.v3.oas.models.PathItem; |
| 28 | +import io.swagger.v3.oas.models.SpecVersion; |
28 | 29 | import io.swagger.v3.oas.models.callbacks.Callback; |
29 | 30 | import io.swagger.v3.oas.models.headers.Header; |
30 | 31 | import io.swagger.v3.oas.models.media.*; |
@@ -2270,6 +2271,88 @@ public static boolean isParent(Schema schema) { |
2270 | 2271 | return false; |
2271 | 2272 | } |
2272 | 2273 |
|
| 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 | + |
2273 | 2356 | public static Schema cloneSchema(Schema schema, boolean openapi31) { |
2274 | 2357 | if (openapi31) { |
2275 | 2358 | return AnnotationsUtils.clone(schema, openapi31); |
|
0 commit comments