0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OpenAPI Generatorでカスタムテンプレートを使いたい

Posted at

OpenAPIを使って自動生成コードを作るときにカスタマイズしたいことありますよね、、
そんな時のために、OpenAPIでカスタムテンプレート作成の方法が公式から説明されています。

・・・長っ!!!

ということでとりあえずカスタムテンプレートを動かしたい人向けに記事を書きます。

バージョン

  • Gradle
    • 7.5
  • OpenAPI Generator Gradle Plugin
    • 6.0.1
build.gradle
plugins {
    id "org.openapi.generator" version "6.0.1"
}

openApiGenerate {
    generatorName = "kotlin-spring"
    templateDir = "$rootDir/openapi/templates"
}

templateDirというプロパティを追加します。
ディレクトリはテンプレートファイルを置きたい場所を指定してください。

テンプレートファイルのデフォルト値は以下にあります。
使用している言語のディレクトリの中身をまるっとtemplateDirにいれればOKです。

あとは対象テンプレートの.mustacheファイルを自分が好きなようにカスタマイズすればそのテンプレートで出力されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?