yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

oneOf not working?

goors opened this issue · comments

I got, for example, geoRestriction that is oneOf GeoAreaSet but the generator is somehow doing this

public class SomeClass {
  public var geoRestriction: GeoRestriction?
}

instead of

public class SomeClass {
  public var geoRestriction: GeoAreaSet?
}

In swift lib, i got like 9.999+ errors. Everything is there but somehow messed up. I got like 772 models with wrong data.

Hi @goors. I can't help without part of an example spec

@yonaskolb I think I ran into an example just now and I'm having the same issue. From the Listen Notes API yaml: https://listen-api.listennotes.com/api/v2/openapi.yaml

After generating the code for this .yaml I'm missing the Results object which contains a oneOf OAS 3 type modifier:

        results:
          type: array
          description: A list of search results.
          items:
            oneOf:
            - $ref: '#/components/schemas/EpisodeSearchResult'
            - $ref: '#/components/schemas/PodcastSearchResult'
            - $ref: '#/components/schemas/CuratedListSearchResult'

Nevermind. I took a look at your TestSpec and the yaml file I was trying to use doesn't specify a discriminator. I modified the ymal to add a discriminator and SwagGen works fine. Thanks!

discriminator: