swagger-api / swagger-api/swagger-codegen

It should be easier to use a different URL with ApiClient

Open
#2,916 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Enhancement: General General: Suggestion
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

My company wants to build a service which could run on any system. We want to use swagger to generate client bindings for the service. We noticed that, at least for Java, the code generator generates code in ApiClient which has a hardcoded URL. There is one method which can take a whole new URL. This existing API is inconvenient because we need to parse a URL and replace parts of it.

We'd like a method which can create a new URL given a scheme, host, and an optional port.

Swagger-codegen version

2.1.6

Swagger declaration file content or url

N/A

Command line used for generation

N/A

Steps to reproduce

Generate bindings in Java for any spec.

Related issues

I could not find a related issue.

Suggest a Fix

I patched a local version of the code generator to update the Java mustache files to do what my company needs. I attached the patch.

patch.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated Java ApiClient and the Java mustache files referenced in the issue and attached patch. Generate bindings for a sample specification, inspect how the existing whole-URL method is used, and compare the result with the requested scheme, host, and optional-port API. Done means the generated client supports constructing a URL from those parts and the generated bindings remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.