Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5511
Closed
Open
Issue created Mar 03, 2020 by Administrator@rootContributor

[REQ] Go Server Default values

Created by: langohr

go-server codegen defaultValue is null

We have extended the go-server templates to generate our own specific code. Here we also use the "{{defaultValue}}" in our templates. We found an issue in the file

org/openapitools/codegen/languages/AbstractGoCodegen.java in the method toDefaultValue

Change toDefaultValue method

By comparing then Codegen class with other Codegen classes this code works better for us: org/openapitools/codegen/languages/AbstractGoCodegen.java LINE 727

    @Override
    public String toDefaultValue(Schema schema) {
        if (schema.getDefault() != null) {
            return schema.getDefault().toString();
        } else {
            schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
            if (schema.getDefault() != null) {
                return schema.getDefault().toString();
            }
            return null;
        }
    }

Is it possible to change that code?

Assignee
Assign to
Time tracking