Skip to content

[Swift] Codegen does not detect file data types #4764

@AnthonyOliveri

Description

@AnthonyOliveri
Description

For Swift codegen, the CodegenOperation's defaultResponse is never set to type file, even when specified in the swagger doc, like so:

responses:
    200:
        description: success
        schema:
            type: file

This means that anything nested in the mustache tags {{#operation}}{{#isResponseFile}} never get evaluated, even for file type responses.

Swagger-codegen version

master branch

Suggest a Fix

The fix is very simple: the function public boolean isDataTypeFile(String dataType) needs to be implemented in SwiftCodegen.java and Swift3Codegen.java. Since these methods are currently not implemented, the response type incorrectly uses the same function from DefaultCodegen.java, which looks for the type string "file" instead of the Swift equivalent "NSURL" or "URL".

I can create a pull request with the fix if you like.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions