swagger-api / swagger-api/swagger-codegen
[Lua] Generator puts whole url in basePath
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Generated code:
local function new_authentication_api(host, basePath, schemes)
local schemes_map = {}
for _,v in ipairs(schemes) do
schemes_map[v] = v
end
local default_scheme = schemes_map.https or schemes_map.http
return setmetatable({
host = host;
basePath = basePath or "https://tapi.telstra.com/v2";
schemes = schemes_map;
default_scheme = default_scheme;
http_username = nil;
http_password = nil;
api_key = {};
access_token = nil;
}, authentication_api_mt)
end
This is using the whole base url for basePath; which is meant to be just the path.
host and schemes are missing defaults.
Swagger-codegen version
d58835e
Swagger declaration file content or url
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l lua -i https://raw.githubusercontent.com/telstra/MessagingAPI-v2/master/docs/swagger/messaging-api-swagger.yaml -o /tmp/tmp.YLECoRioDm
Suggest a fix/enhancement
Could either break down the default target to host+scheme+path. Or change the call to new_from_uri to just take the uri as a string (instead of as broken-down table).
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
Reproduce the Lua generation with the provided Swagger declaration and command, then inspect the generated new_authentication_api constructor and the new_from_uri call mentioned in the issue. The fix is done when the default URL is represented with separate scheme, host, and path values, and host and schemes receive defaults without putting the full URL in basePath.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100