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
  • #2260
Closed
Open
Issue created Feb 28, 2019 by Jim Schubert@jimschubertContributor

[discussion] defaultValue for client vs server models

Description

The following concern was raised in chat:


Writing a client generator: Do clients normally include the defaultValue for model vars? Shouldn't they be filled in by the server (the consumer) and so, not be included in client code?

The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schema-object

So, I'm thinking that "consumer of the input" is the server, not the generated client code, and so the defaultValue might be in a comment, but should not be sent to the server in requests and should not be automatically added to responses where the server didn't include it.


Should we consider an option to support a concept such as separating input vs response models? The idea would be to provide default values on server side input processing, but not for client side model construction (allowing server to provide default for any missing properties).

openapi-generator version

n/a

OpenAPI declaration file content or url
Command line used for generation

n/a

Steps to reproduce

n/a

Related issues/PRs

n/a

Suggest a fix/enhancement
Assignee
Assign to
Time tracking