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
  • !11530

PROPOSAL: Java AST-based Client

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/eak24/javaparser_ast_client into master Feb 05, 2022
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 5

Created by: eak24

This PR attempts to demonstrate the power, flexibility and maintainability of creating generated code using an AST parser instead of mustache templates. With a very readable 10 lines of code and no mustache templates, I was able to convert a collection of CodeGenModels into valid Java classes with fields and getters and setters, with proper indentation and everything. This method completely outsources the burden of string manipulation, linting and a lot of the frustrating parts of maintaining and thinking about the code structure to the JavaParser package (for Java). I'd argue that reading and thinking about this code is far easier than trying to reason about the combination of Mustache templates and String wrangling that the generators currently use. A downside is that you have to use a different AST generator for each language. But on the other side, that allows for each generator to be written in the language of the generated code itself. This isn't really meant to replace the current generators at all, but rather demonstrate the power of working with the AST directly.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/eak24/javaparser_ast_client