yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated client does not compile if path parameter is an alias for a primitive type

malteburkert opened this issue · comments

The following spec describes a path for fetching a sample object by its id. The id is of type EntityId in order to specify the format.

{ "openapi": "3.0.0", "servers": [ { "url": "http://my.sample.endpoint.com/" } ], "info": { "version": "1.0.0", "title": "My Sample API", "contact": { "email": "info@wapp.gmbh", "name": "WAPP GmbH", "url": "https://wapp.gmbh" } }, "paths": { "/samples/{sampleId}": { "parameters": [ { "in": "path", "name": "sampleId", "schema": { "$ref": "#/components/schemas/EntityId" }, "required": true } ], "get": { "operationId": "getSampleById", "description": "Returns a sample object with sampleId", "responses": { "200": { "description": "Successfully returned a sample object with sampleId", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SampleEntity" } } } } } } } }, "components": { "schemas": { "EntityId": { "type": "integer", "format": "int64" }, "SampleEntity": { "type": "object", "properties": { "id": { "$ref": "#/components/schemas/EntityId" }, "name": { "type": "string" } } } } } }

The swift compiler issues the following error in the corresponding request class for the operation getSampleById where the dynamic path variable is constructed:

public override var path: String { return super.path.replacingOccurrences(of: "{" + "sampleId" + "}", with: "\(self.options.sampleId.encode())") }

Missing argument for parameter 'to' in call

ezoic increase your site revenue