yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to reference types inside generated API client using module's namespace #template

Kastet opened this issue · comments

If using Cocoapods (not sure if true for other DMs), public struct {{ options.name }} will be matching your generated API client Swift module name which breaks types lookup. For example, if your codebase or another module has a type User and your generated API client has User, then referencing User from generated API client via {{ options.name }}.User won't work.

Apparently, it's a limitation of Swift compiler - https://bugs.swift.org/browse/SR-1386

Suggest moving away from public struct {{ options.name }} by splitting it up into public struct Config that holds coding options and Server and public struct Operation to namespace operations.

What do you think @yonaskolb ?

@yonaskolb have you had a chance to review this suggestion? Do you see a way to work around this problem without making braking changes?