OpenAPITools / OpenAPITools/openapi-generator
[REQ] [GO] Support yaml endpoints
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
My API has two kinds of endpoints, most of them use application/json but a few rely on text/x-yaml. As it is today, we are forced to override the generated code in order to decode the request and encode the response properly for a YAML endpoint. It would be extremely helpful if the generator could generate code that supports encoding/decoding YAML.
Describe the solution you'd like
Be able to define an endpoint that accepts text/x-yaml and the go-server generator can generate an endpoint implementation capable of encoding/decoding YAML.
Describe alternatives you've considered
So far we could only achieve this by replacing the handler function for each YAML route, but this is not a good approach, it would be nice to have it out of the box.
Example of what we are doing:
routes[c.getRouteIndex("GetRunResultJUnit")].HandlerFunc = c.GetRunResultJUnit
routes[c.getRouteIndex("GetTestVersionDefinitionFile")].HandlerFunc = c.GetTestVersionDefinitionFile
Additional context
Example of endpoint:
/test.yaml:
put:
tags:
- definition
summary: Update a test using its definition
operationId: updateTestDefinition
requestBody:
content:
text/x-yaml:
schema:
type: object
properties:
id:
type: string
name:
type: string
# rest of the properties
responses:
200:
description: Test updated successfully
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the go-server generator's handling of request and response content types, then compare it with the generated JSON handler paths and the route HandlerFunc overrides shown in the issue. Done means an endpoint declaring text/x-yaml can use generated code to decode requests and encode responses without replacing its handler manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100