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
  • #3898
Closed
Open
Issue created Sep 16, 2019 by Administrator@rootContributor

[Question] [CSHARP] Disable validation of required fields in model constructor and json

Created by: BenedicteLeo

I am attempting to disable client model validation entirely in C# in order to run negative tests on my service. More specifically, I need my client model classes to not perform null checks in the constructors, and the Json serializer to ignore empty fields. Some of the fields are required in my yaml, but I specifically want to send null values to the service to test its behavior. Is there an easy way to achieve this?

I have set "validatable": false in the config json, but I don't know what this setting is affecting (but it's not what I need).

openapi-generator version

I'm running version 4.1.2 with Swagger 3.0.

Command line used for generation

java -jar openapi-generator-cli.jar generate -i D:...\Blah.yaml -g csharp --config D:...\GeneratorConfig.json

Steps to reproduce
  1. Have a yaml model with a required field
  2. Run the above command line operation with a json config containing: {
    "validatable": false, }
  3. Check the model constructor, and observe that there are null checks on the required params.
Assignee
Assign to
Time tracking