swagger-api / swagger-api/swagger-codegen
Why is port in `swagger-codegen generate` not added to basePath in generated clients?
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
It may not be a bug. I would just appreciate some clarification on how basePath is defined when generating clients.
I'm currently generating my Android and Swift client through:
SPEC="http://localhost:8080/api/swagger.json"
swagger-codegen generate -v \
-i $SPEC \
-l swift4 \
-c ios-config.json \
-o ios
swagger-codegen generate -v \
-i $SPEC \
-l android \
-c android-config.json \
-o android
Even though SPEC url contains port 8080, the generated code does not add it to basePath ariable:
open class ClientAPI {
open static var basePath = "http://localhost/api"
open static var credential: URLCredential?
open static var customHeaders: [String:String] = [:]
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
}
Swagger-codegen version
HomeBrew Swagger CodeGen v2.2.3
Swagger declaration file content or url
{
"swagger": "2.0",
"info": {
"description": "Blah",
"version": "1.0",
"title": "Blah",
"contact": {
"name": "contact@blah.com"
}
},
"basePath": "/api",
"tags": [{
"name": "v1"
}],
"schemes": [
"http"
],
"paths": {},
"definitions": {}
}
Command line used for generation
Added above.
Steps to reproduce
Execute the command above without the configuration parameters.
Related issues/PRs
N/A.
Suggest a fix/enhancement
N/A.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the shown swagger-codegen generate commands with SPEC set to http://localhost:8080/api/swagger.json, using ios-config.json and android-config.json. Inspect the generated Swift ClientAPI basePath and the corresponding Android client, then trace how the generator handles the input URL and Swagger basePath. Done means the port behavior is corrected or clearly documented for both generators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, swift
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100