swagger-api / swagger-api/swagger-codegen

[go] Path of the remote file added to the pattern when generating a server

Open
#11,809 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When using option -i to grab the specs from the web to generate a server, the path of the specs is added to the Route pattern

The command used is

swagger-codegen generate -i  https://forge.3gpp.org/rep/all/5G_APIs/-/blob/Rel17-draft-TSG96/TS29122_PfdManagement.yaml  -l go-server -o server

The result at routers.go is

var routes = Routes{
	Route{
		"Index",
		"GET",
		"/rep/all/5G_APIs/-/raw/Rel17-draft-TSG96//TS29122_PfdManagement.yaml/",
		Index,
	},

	Route{
		"DeleteIndApplicationPFDManagement",
		strings.ToUpper("Delete"),
		"/rep/all/5G_APIs/-/raw/Rel17-draft-TSG96//TS29122_PfdManagement.yaml/{scsAsId}/transactions/{transactionId}/applications/{appId}",
		DeleteIndApplicationPFDManagement,
	},
...

As you can see the 3rd argument on the Route (pattern) includes the path of the file we used

Swagger-codegen version

3.0.34

Swagger declaration file content or url

https://forge.3gpp.org/rep/all/5G_APIs/-/blob/Rel17-draft-TSG96/TS29122_PfdManagement.yaml

Command line used for generation
swagger-codegen generate -i  https://forge.3gpp.org/rep/all/5G_APIs/-/blob/Rel17-draft-TSG96/TS29122_PfdManagement.yaml  -l go-server -o server
Steps to reproduce

check routers.go

Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the issue with the provided swagger-codegen command and inspect the generated routers.go. Compare the route patterns with the paths in the remote OpenAPI specification; done means the generated patterns contain the API routes without the remote file path prefix.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design, tooling
Issue type
Bug
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.