OpenAPITools / OpenAPITools/openapi-generator

[REQ] [GO] Add support for golang []byte with format: byte

Open
#8,351 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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.

When generating golang code from openapi 3.0 the following snippet

components:
   schemas:
      randomByteString:
         type: string
         format: byte

results in the following

RandomByteString *string `json:"randomByteString,omitempty"

Describe the solution you'd like

I want the .yaml snippet above to generate the following

RandomByteString *[]byte `json:"randomByteString,omitempty"

This is in accordance with the result in Java as seen from the sample in the repo:
inlineObject3.java

public static final String JSON_PROPERTY_BYTE = "byte";
private byte[] _byte;

Describe alternatives you've considered

There are no alternatives.

Additional context

No additional context needed

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

Start by tracing the Go generator's handling of an OpenAPI schema with type string and format byte, then compare its output with the requested *[]byte result and the Java example in inlineObject3.java. Done means the YAML schema generates the requested Go field type while preserving the shown JSON tag behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.