-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
After some investigation, the test issue when changing the type binary from URL to Data, is related to the code in ModelUtils line 659.
Lines 2059 to 2062 in 3894aa4
| } else if (ModelUtils.isFileSchema(schema)) { | |
| return "file"; | |
| } else if (ModelUtils.isBinarySchema(schema)) { | |
| return SchemaTypeUtil.BINARY_FORMAT; |
Lines 643 to 660 in 3894aa4
| public static boolean isBinarySchema(Schema schema) { | |
| if (schema instanceof BinarySchema) { | |
| return true; | |
| } | |
| if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType()) | |
| && SchemaTypeUtil.BINARY_FORMAT.equals(schema.getFormat())) { // format: binary | |
| return true; | |
| } | |
| return false; | |
| } | |
| public static boolean isFileSchema(Schema schema) { | |
| if (schema instanceof FileSchema) { | |
| return true; | |
| } | |
| // file type in oas2 mapped to binary in oas3 | |
| return isBinarySchema(schema); | |
| } |
The binary type will be considered as file type.
To add some interesting bits to the discussion
The Kotlin Client generator, considers binary as BiteArray (or Data in Swift) and file as java.io.File (or URL in Swift)
Lines 159 to 165 in 3894aa4
| typeMapping.put("file", "java.io.File"); | |
| typeMapping.put("array", "kotlin.Array"); | |
| typeMapping.put("list", "kotlin.collections.List"); | |
| typeMapping.put("set", "kotlin.collections.Set"); | |
| typeMapping.put("map", "kotlin.collections.Map"); | |
| typeMapping.put("object", "kotlin.Any"); | |
| typeMapping.put("binary", "kotlin.ByteArray"); |
The Java Client generator, considers binary as byte[], and file as java.io.File.
Since this is a big change on how files/binary is treated in the Swift Generator that is also a breaking change, and doing things differently from the other generators worries me a bit, so I just would like to be sure that this is the right move, but let's continue this discussion on the new PR..
Originally posted by @4brunu in #9206 (comment)