8000 Proposal: x-omitempty for general types · Issue #1623 · go-swagger/go-swagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Proposal: x-omitempty for general types #1623
Closed
@zhuangqh

Description

@zhuangqh

Problem statement

Currently, we use x-omitempty to exclude null array value. related PR #1189
Maybe x-omitempty can support general type to control the omityempty tag.

Foo:
  type: "object"
  properties:
    hasOmitEmptyTrue:
      type: string
      x-omitempty: true
    hasOmitEmptyFalse:
      type: string
      x-omitempty: false

produce

type Foo struct {
	// has omit empty false
	HasOmitEmptyFalse string `json:"hasOmitEmptyFalse"`
	// has omit empty true
	HasOmitEmptyTrue string `json:"hasOmitEmptyTrue,omitempty"`
}

Swagger specification

Steps to reproduce

Environment

swagger version: x.x.x
go version: x.x.x
OS:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmodelRelated to swagger generate model command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0