Skip to content
GitLab
    • Explore Projects Groups Snippets
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
  • !4762

[core] Validation properties standardization

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jim Schubert requested to merge github/fork/jimschubert/validation-properties-standardization into master 5 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 7

This should address #4653 (closed)

The request was to add validation properties to CodegenModel, where CodegenModel may be used to represent reusable schemas which don't necessary result in a generated model (see isString, isInteger, etc). Those use cases are legacy functionality from before there was a standardized structure in swagger-parser (now, Schema). I couldn't find any usages in template code, but that's not to say that users with customized templates aren't relying heavily on CodegenModel and legacy functionality. I've added the set of validation properties to CodegenModel to address this issue, but I think we should work out a deprecation strategy if CodegenModel is no longer meant to be used for primitive schemas. That is, an OpenAPI Schema representing a primitive type should never be a model in generated code.

The heart of the discussion in the linked issue is this:

  • CodegenModel appears to be considered the "most proper" transformation from Schema to some type within OpenAPI Generator
  • The ask is to not drop JSON Schema Validation Properties whenever we convert from a Schema instance to one of the Codegen* types in OpenAPI Generator
  • The use case this would allow is model reuse in generated code which requires pre-condition and post-condition checks.

This PR will address issues in our other Codegen* types, such as the copy method on CodegenParameter would previously not copy pattern, minimum or maximum. CodegenResponse previously had not validation properties. The previous assumption seems to be that CodegenResponse, for instance, didn't require validation; that's not really the case in microservices, and especially not in OLTP where data consistency is key and something like pattern or length checks could prevent security breaches.

I'm opening this for feedback. If reviewers feel that CodegenModel does not require these validation properties, I'd prefer to remove them from that class.

cc @OpenAPITools/generator-core-team cc @spacether

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Loading
Loading

Activity


Please register or sign in to reply
0 Assignees
None
Assign to
Reviewer
XhmikosR's avatar
XhmikosR
Request review from
Labels
2
docs v5
2
docs v5
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: twbs/bootstrap!31795
Source branch: github/fork/jimschubert/validation-properties-standardization

Menu

Explore Projects Groups Snippets