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
  • Wiki
  • Customizing client code generation

Customizing client code generation · Changes

Page history
Initial Wiki authored May 13, 2018 by Jeremie Bresson's avatar Jeremie Bresson
Show whitespace changes
Inline Side-by-side
Customizing-client-code-generation.md 0 → 100644
View page @ 016d8b1b
Sometimes you don't want the codegen to make a model for you--you might want to just include one that already exists in your codebase. Say you already have a `User` object and want to reuse that, which has a different model package from the other generated files:
First, indicate that the class is already included by default. This will keep the codegen from trying to generate the class:
```scala
override def defaultIncludes = super.defaultIncludes ++ Set("User")
```
This statement will take the existing `defaultIncludes` and add `User` to it.
Next, if the `User` class is a different package, add an `importMapping` to tell the generator to include that import wherever `User` is used:
```scala
override def importMapping = super.importMapping ++ Map(
"User" -> "com.yourpackage.existingModels.User")
```
Now the codegen will know what to import from that specific package.
\ No newline at end of file
Clone repository
  • API client generator HOWTO
  • Building your own Templates
  • Customizing client code generation
  • FAQ
  • Git Branches
  • Home
  • How to add a generator for a new language or framework
  • Integration Tests
  • Migration Guide
  • Mustache Template Variables
  • Pull Request Checklist
  • Release Checklist
  • Samples folder
  • Server stub generator HOWTO
  • Vendor Extensions
View All Pages