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
  • Merge requests
  • !1776

[python-client] Add model default values

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/spacether/issue_1748_add_model_default_values into master Dec 29, 2018
  • Overview 0
  • Commits 11
  • Pipelines 0
  • Changes 197

Created by: spacether

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/python-petstore.sh and ./bin/security/python-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
    • @taxpon
    • @frol
    • @mbohlool
    • @cbornet
    • @kenjones-cisco
    • @tomplus
    • @wing328

Description of the PR

This PR lets python client users set model defaults on integers, numbers, and arrays when they are not currently able to in a swagger2.0 spec. The new code loads model variable examples into the model variable default value if the default is not already set and an example exists for the variable. Fixes this issue: https://github.com/OpenAPITools/openapi-generator/issues/1748

Reasons to do this: The current swagger-parser is not including default values that are float, integer, or array when processing a swagger2.0 spec. So in a swagger 2.0 spec, there is no way to set defaults on:

  • integers
  • numbers
  • arrays

This PR adds in fallback code which uses and assigns a spec example value as the default value if one exists in the spec. So it uses examples to set defaults on the types

  • string
  • boolean
  • integers
  • numbers
  • arrays

Tests

  • test_type_holder_example.py added to verify that examples are loaded into defaults
  • test_type_holder_default.py added to verify what default-only definition does and does not work
  • samples updated to pass CircleCi tests (173 files)
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/spacether/issue_1748_add_model_default_values