-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a GoLang client from specs where API responses with '5XX' status codes are defined, there is a syntax error in the generated client originating from the mustache template for GoLang which is missing an opening '{' for an if statement comparing statusCode >= 500
openapi-generator version
6.2.0
OpenAPI declaration file content or url
gobug.yaml:
openapi: 3.0.2
info:
title: Bug API
version: '0.0'
contact:
name: Curvegrid
description: Go Client Bug API.
servers:
- url: 'https://{hostname}'
variables:
hostname:
default: localhost:8080
description: Bug Test Server.
tags:
- name: test
paths:
/test:
get:
operationId: test
summary: Test
description: Test Go Client Bug.
tags:
- test
responses:
'200':
description: OK
4XX:
$ref: '#/components/responses/ClientError'
5XX:
$ref: '#/components/responses/ServerError'
components:
schemas:
Error:
type: object
x-tags:
- error
example:
status: 404
message: Page Not Found
description: An error response.
additionalProperties: false
properties:
status:
type: integer
description: The unique error code.
message:
type: string
description: The human-readable error message.
required:
- status
- message
responses:
ClientError:
description: Client error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
ServerError:
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Generation Details
Steps to reproduce
openapi-generator generate -g go -i gobug.yaml -o go_clientcd go_client
Observe syntax error: missing opening '{' atapi_test_.goline 117
Related issues/PRs
Suggest a fix
Fixable by adding mentioned missing { to
| if localVarHTTPResponse.StatusCode >= 500 |
Reactions are currently unavailable