swagger-api / swagger-api/swagger-codegen

Generating clients for multiple languages

Open
#4,601 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I am currently trying to create Swagger clients using the Swagger-Codegen for multiple languages. Everything is fine for a single language, but when doing it for multiple languages the complexity seems to increase unnecessarily.

Some of the options in my config.json file are not supported/available in other languages and therefore I would have to create a config file for every language, which makes it for example ridiculous complex to do a version bumb. So my current approach would be to write a script that calls the Swagger-Codegen several times passing different config parameters per language. However, this seems more like a hack than a solution, so I was wondering if I missed anything in the docs or if any of you came up with a better solution?

In the end I would like to generate clients for most of the available languages of the codegen.

A possible solution for the codegen could be to extend the current config file format. Maybe it would be possible to create a structure like this:

{
version: 1.0
groupId: "group"
artifactId: "artifact"
languages: {
  java: {
    library: "okhttp-gson"
  },
  php: {
    phpOnlyValue: "something"
  },
  someOtherLang: {
    foo: "bar"
  }
}
}

The idea would be to have a lot of common attributes that only need to be changed once, for example the version, the name of of the client, and the name of the organization (groupId).

If you compare the config options for php and java they are completely different. It would be nice to have a common subset of configs for each language (not sure if this is even possible in theory).

What do you think? Is there a different/better way to do this right now?

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 Swagger-Codegen documentation and the existing config.json format, then compare the Java and PHP configuration options. Define how common settings and language-specific settings should coexist, and consider how multi-language generation would confirm that the proposed configuration is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, json, php
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.