yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API.Server.main not found

haemi opened this issue · comments

my openapi.yml file has a server entry at the end:

servers:
- url: http://localhost:8080/
  description: Local development version

which leads to the following APIClient.swift:

public static var `default` = APIClient(baseURL: API.Server.main)

This gives the compiler error Type 'API' has no member 'Server'. Is this a bug in SwagGen oder is something missing in my openapi.yml?

I have encountered the same issue.

In my case the servers are right after info on the top of the .yml file:

openapi: 3.0.1
info:
  title: ...
  description: ...
  version: ...
servers:
- url: http://...
...

I haven't looked at SwagGen implementation, but replacing "API.Server.main" with the actual url fixes the issue:

public static var `default` = APIClient(baseURL: "http://...")

I found that without specifying tags, servers won't show.

Hi i have the same problem.
I found that in the template file API.swift the {% if tags%} block is closed at the end of the file, so it turns out that the server code is generated only if there are tags. Perhaps this was done on purpose?
I found a diff of a commit that looks like a random bug when refactoring and copying code
950f667#diff-5fd3bee400cfc6aadd6d9d1b798792be

commented

I fixed it!

ezoic increase your site revenue