yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enum schemas not found by compiler

benrudhart opened this issue · comments

Hi @yonaskolb,
I'm having trouble with enums situated at root level: Supposed we have a (simplified) scheme like this:

openapi: 3.0.3
  version: 1.0.0
  title: Test
      type: string
      - first
      - second

It defines the enum Category which should be available in the API framework.

It is usable if I import it via import enum API.Category, and can simply be used as API.Category.first.
In this case I have to specify the namespace (API) since Foundation is already declaring another Category.

But if the same file needs other objects from API I'd simply like to use import API. If I do so some code like API.Category.first doesn't compile anymore:
Type 'API' has no member 'Category'

I've looked for similar issues here but couldn't find it. I also noticed that this is true for all enum schemas that are situated in the "root" level of API. Most often it's probably not a problem since there's no ambiguity and API names isn't required. In those cases it's fine.

Do you know what causes this issue and how I can fix it?

Don't hesitate contacting me if you need further details.

This seems to be related to #159

ezoic increase your site revenue