yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
626 stars 146 forks source link

Add Apple App Store Connect Spec #249

Open Blackjacx opened 3 years ago

Blackjacx commented 3 years ago

I added and build the Apple App Store Connect spec.

Resolves #248 - App Store Connect Open API Spec Doesn't Compile

yonaskolb commented 3 years ago

Thanks @Blackjacx! There were some issues in master and tests weren't running. Could you please rebase off current master

Blackjacx commented 3 years ago

Alright, that's done 👍 I built the spec again and now this PR has only half of the changes!?

Blackjacx commented 3 years ago

Hey there, did you find the time to look into it? Generating the ASC API would be a massive time saver for me :D Tell me if I can do something.

mikhailmaslo commented 3 years ago

Did it work for you @Blackjacx? Cause I tried to build it and got same errors as without this PR changes (and CI check indicates the same errors)

stherold commented 3 years ago

The happen when I run swift build on the generated files. But actually I have no clue why they happen. Yought one of you can help. It is due to how the swift files are generated I guess. This is the main problem I think (public class Links: APIModel):

self.`self` = `self`

The API model has an attribute called self which is generated as String? but as default value the generator sets

`self` 

which is not a string. Ca I change this behavior via templates?

stherold commented 3 years ago

Hmm your update looks good @yonaskolb but did the CI run again? It looks like it reports the same errors. I compiled the new version locally. Now the following JSON produces incorrect value (maybe this is also an error in the spec - I donw understand why they specify one of of the same type):

"AppCategoryResponse" : {
        "type" : "object",
        "title" : "AppCategoryResponse",
        "properties" : {
          "data" : {
            "$ref" : "#/components/schemas/AppCategory"
          },
          "included" : {
            "type" : "array",
            "items" : {
              "oneOf" : [ {
                "$ref" : "#/components/schemas/AppCategory"
              }, {
                "$ref" : "#/components/schemas/AppCategory"
              } ]
            }
          },
          "links" : {
            "$ref" : "#/components/schemas/DocumentLinks"
          }
        },
        "required" : [ "data", "links" ]
      }

The result is then:

public class AppCategoryResponse: APIModel {
    [...]
    public var included: [Included]?

But it should probably be:

public class AppCategoryResponse: APIModel {
    [...]
    public var included: [AppCategory]?