[Golang][go-gin-server]can not use the param of the path
Created by: kemokemo
Description
The path with param does not be generated properly. ex) /pet/{petId}
openapi-generator version
3.3.0-SNAPSHOT (master)
OpenAPI declaration file content or url
extracted_petstore.yaml
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/v2'
info:
description: >-
This is a sample server Petstore server. For this sample, you can use the api key
`special-key` to test the authorization filters.
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: pet
description: Everything about your Pets
paths:
'/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- api_key: []
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
components:
requestBodies:
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
schemas:
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: '#/components/schemas/Category'
name:
type: string
example: doggie
photoUrls:
type: array
xml:
name: photoUrl
wrapped: true
items:
type: string
tags:
type: array
xml:
name: tag
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: Pet
Command line used for generation
generate -i extracted_petstore.yaml -g go-gin-server -o go-gin-server
Steps to reproduce
Related issues/PRs
Issue #1047 (closed) PR #1048
Suggest a fix/enhancement
routers.go
generated by the current master.
var routes = Routes{
{
"Index",
"GET",
"/v2/",
Index,
},
{
"GetPetById",
strings.ToUpper("Get"),
"/v2/pet/{petId}",
GetPetById,
},
}
This code should be below:
var routes = Routes{
{
"Index",
"GET",
"/v2/",
Index,
},
{
"GetPetById",
strings.ToUpper("Get"),
"/v2/pet/:petId",
GetPetById,
},
}