Skip to content

Feature: Strip repository path from component name #9

@jorygeerts

Description

@jorygeerts

Right now, the full repository path to each component is visible in the generated Swagger JSON.

For instance:

{
  "components": {
    "schemas": {
      "gitlab.mycompany.local.mygroup.myproject.internal.web.SomeInput": {
        "type": "object"
      }
    }
  }
}

I'd like to be able to strip (or modify) this, so the component name is simply web.SomeInput (or internal.web.SomeInput, or something like that).

I see three basic option for this, each with its own pro's and cons.

Always strip the domainname and group (and project?)
Pro's: easy to implement, doesn't make anything harder to use.
Cons: Collisions are possible. Any users who are (for whatever reason) relying on component names won't be happy.

Make stripping parts of the component path a runtime option
Possibly by adding CLI options, eg --strip-component gitlab.mycompany.local/mygroup
Pro's: flexible, opt-in
Cons: Makes the tool a bit harder to use (for users who would want to use this). Collisions are also possible, but now the user would have a way to control this.

Support defining an alias somewhere
If it where possible to define a component alias (either on the struct or the package, or perhaps even during import (but not to be confused by import aliasses) this would grant the ultimate flexibility.
Pro's: Opt in, maximal flexibility
Cons: Even more comments throughout the source code that only serve the Swagger documentation. Depending on the "scope" of the alias, moving a struct to another file may unintentionally change the way the name of the component ends up on the Swagger JSON.

mikunalpha is this an idea you could get behind? If so, I'd be happy to implement it. If not, I'll just add some kind of string replace in our CI scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions