Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go-gin-server] Add nullable support #1766

Closed
alex-korobko opened this issue Dec 28, 2018 · 6 comments
Closed

[go-gin-server] Add nullable support #1766

alex-korobko opened this issue Dec 28, 2018 · 6 comments

Comments

@alex-korobko
Copy link
Contributor

Description

It seems like nullable is not supported yet for primitive types in model generation for Go . I checked for go-gin-server generation but it seems to be language wide issue.

openapi-generator version

openapi-generator version 3.3.4

OpenAPI declaration file content or url

Here is the simple model to check
https://editor.swagger.io/?url=https://gist.github.com/alex-korobko/8d3f4fbe817d4f1420ab779c91dddf94

Command line used for generation
openapi-generator generate --generator-name go-gin-server -i $SPEC -o $AUTO_CODE_DIR
Steps to reproduce

Use spec from the gist file (the link is above in the description).
Try to generate models for generator go-gin-server

Related issues/PRs

None found so far neither opened nor closed.

Suggest a fix/enhancement
@auto-labeler
Copy link

auto-labeler bot commented Dec 28, 2018

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@alex-korobko
Copy link
Contributor Author

BTW when openapi-generator generates references, it uses pointers.
For example, for the spec

    Product:
      type: object
      properties:
        ProductDimensions: # only provided if ProductDimensions was specified in the Product request
          $ref: '#/components/schemas/ProductDimensions'

the generated model contains pointer to the ProductDimensions struct

package openapi

type Product struct {
	ProductDimensions *ProductDimensions `json:"ProductDimensions,omitempty"`

@ackintosh
Copy link
Contributor

@alex-korobko Thanks for reporting this issue!

cc Technical Committee: @antihax (2017/11) @bvwells (2017/12) @grokify (2018/07) @kemokemo (2018/09

@alex-korobko
Copy link
Contributor Author

Thanks for the attention to the issue, @ackintosh ! I'd be glad to help to fix the issue, if you guys provide some initial guidance.

@ackintosh
Copy link
Contributor

ackintosh commented Jan 3, 2019

@alex-korobko Thanks! There are some PRs helps you as a reference which adds nullable support to the generator. 💡 :

You may use the mustache tag {{#isNullable}}...{{/isNullable}} {{^isNullable}}...{{/isNullable}} to achieve the nullable feature. ( templates of go-gin-server is here ) 📝

Please let us know if you need help. 😉

@alex-korobko
Copy link
Contributor Author

Created PR with updated mustache files for all types of Go lang generators.
#1869

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants