[Go] Optional values should be pointers
Created by: langston-barrett
Description
If a field of a struct isn't specified as required
, then it should be a pointer to that value so that one can differentiate between unset by the user or set to the "zero value". See the following Go playground: https://play.golang.org/p/85r_JbH5XVr
See also e.g. this Stackoverflow answer.
openapi-generator version
Docker container
OpenAPI declaration file content or url
---
openapi: 3.0.0
info:
title: unset
version: 0.1.0
paths:
"/foo":
get:
summary: foo
responses:
'200':
description: OK
content:
application/xml:
schema:
"$ref": "#/components/schemas/Bar"
components:
schemas:
Bar:
properties:
X:
type: integer
Y:
type: integer
required:
- X