forked from loafle/openapi-generator-original
55 lines
34 KiB
HTML
55 lines
34 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width">
|
||
<meta name="generator" content="Docusaurus">
|
||
<link rel="preconnect" href="https://www.google-analytics.com">
|
||
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-132927057-1","auto"),ga("send","pageview")</script>
|
||
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
||
<link rel="preconnect" href="https://www.google-analytics.com">
|
||
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-132927057-1","auto"),ga("send","pageview")</script>
|
||
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
||
<script src="https://buttons.github.io/buttons.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
|
||
<script src="/js/code-block-buttons.js"></script>
|
||
|
||
<title data-react-helmet="true">Plugins</title>
|
||
|
||
<meta data-react-helmet="true" http-equiv="x-ua-compatible" content="ie=edge"><meta data-react-helmet="true" property="og:title" content="OpenAPI Generator · Generate clients, servers, and documentation from OpenAPI 2.0/3.x documents"><meta data-react-helmet="true" property="og:image" content="https://openapi-generator.tech/img/docusaurus.png"><meta data-react-helmet="true" property="twitter:image" content="https://openapi-generator.tech/img/docusaurus.png"><meta data-react-helmet="true" name="twitter:image:alt" content="Image for OpenAPI Generator · Generate clients, servers, and documentation from OpenAPI 2.0/3.x documents"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="description" content="## Maven"><meta data-react-helmet="true" property="og:description" content="## Maven"><meta data-react-helmet="true" property="og:url" content="https://openapi-generator.tech/docs/plugins">
|
||
|
||
<link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.png">
|
||
|
||
|
||
<link rel="stylesheet" href="/styles.ec5417b5.css">
|
||
|
||
</head>
|
||
<body>
|
||
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}function e(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}var n=window.matchMedia("(prefers-color-scheme: dark)");n.addListener((function(n){null===e()&&t(n.matches?"dark":"")}));var a=e();null!==a?t(a):n.matches&&t("dark")}()</script>
|
||
<div id="__docusaurus">
|
||
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a aria-current="page" class="navbar__brand active" href="/"><img class="navbar__logo" src="/img/mono-logo.svg" alt="OpenAPI Tools logo"><strong>OpenAPI Generator</strong></a><a class="navbar__item navbar__link" href="/docs/installation">Getting Started</a><a class="navbar__item navbar__link" href="/docs/generators">Generators</a><a class="navbar__item navbar__link" href="/docs/roadmap">Roadmap</a><a class="navbar__item navbar__link" href="/docs/faq">FAQ</a><a class="navbar__item navbar__link" href="/team">Team</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a class="navbar__item navbar__link" activeclassname="navbar__link--active" to="https://api.openapi-generator.tech" href="https://api.openapi-generator.tech">API</a></div><div class="navbar__items navbar__items--right"><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_1gtM"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_keGJ moon_1gwN"></span></div><div class="react-toggle-track-x"><span class="toggle_keGJ sun_3CPA"></span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input type="search" id="search_input_react" placeholder="Search" aria-label="Search" class="navbar__search-input search-bar"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a aria-current="page" class="navbar__brand active" href="/"><img class="navbar__logo" src="/img/mono-logo.svg" alt="OpenAPI Tools logo"><strong>OpenAPI Generator</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/installation">Getting Started</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/generators">Generators</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/roadmap">Roadmap</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/faq">FAQ</a></li><li class="menu__list-item"><a class="menu__link" href="/team">Team</a></li><li class="menu__list-item"><a class="menu__link" href="/blog">Blog</a></li><li class="menu__list-item"><a class="menu__link" activeclassname="navbar__link--active" to="https://api.openapi-generator.tech" href="https://api.openapi-generator.tech">API</a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_1kjD"><div class="docSidebarContainer_1cYp"><div class="sidebar_1kLs"><div class="menu menu--responsive"><button aria-label="Open Menu" class="button button--secondary button--sm menu__button" type="button"><svg class="sidebarMenuIcon_2vk4" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 32 32" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#!">Getting Started</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/installation">CLI Installation</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/plugins">Plugins</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/online">Online</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/usage">Usage</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/globals">Global Properties</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/configuration">Configuration Options</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/file-post-processing">File post-processing</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Extending</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/templating">Using Templates</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/customization">Customization</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/debugging">Debugging</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/integrations">Workflow Integrations</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Contributing</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/contributing">Guidelines</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/code-of-conduct">Code of Conduct</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/contribute-building">Building the code</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/new-generator">Create a New Generator</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">About</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/roadmap">Roadmap</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/swagger-codegen-migration">Migrating from Swagger Codegen</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/fork-qna">Swagger Codegen Fork: Q&A</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Releases</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/release-summary">Release Summary</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/release-3-0-0">Release Notes: 3.0.0</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">API</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/generators">Generators List</a></li></ul></li></ul></div></div></div><main class="docMainContainer_FFX1"><div class="padding-vert--lg"><div class="container"><div class="row"><div class="col"><div class="docItemContainer_2cwg"><article><header><h1 class="docTitle_1vWb">Plugins</h1></header><div class="markdown"><h2><a aria-hidden="true" tabindex="-1" class="anchor" id="maven"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#maven" title="Direct link to heading">#</a>Maven</h2><p>A Maven plugin to support the OpenAPI generator project</p><h3><a aria-hidden="true" tabindex="-1" class="anchor" id="example"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#example" title="Direct link to heading">#</a>Example</h3><p>Add to your <code>build->plugins</code> section (default phase is <code>generate-sources</code> phase)</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-xml codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">plugin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">org.openapitools</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">openapi-generator-maven-plugin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token comment" style="color:rgb(98, 114, 164)"><!-- RELEASE_VERSION --></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">5.1.0</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token comment" style="color:rgb(98, 114, 164)"><!-- /RELEASE_VERSION --></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">executions</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">execution</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">goals</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">goal</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">generate</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">goal</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">goals</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">configuration</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">inputSpec</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">${project.basedir}/src/main/resources/api.yaml</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">inputSpec</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">generatorName</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">java</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">generatorName</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">configOptions</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">sourceFolder</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">src/gen/java/main</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">sourceFolder</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">configOptions</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">configuration</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">execution</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">executions</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">plugin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre><p>Followed by:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-bash codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token plain">mvn clean compile</span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre><p>For full details of all options, see the <a href="https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin">plugin README</a>.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor" id="dependencies"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#dependencies" title="Direct link to heading">#</a>Dependencies</h3><p>The generated models use commonly used Swagger v2 annotations like <code>@ApiModelProperty</code>. A user may add Swagger v3 annotations:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-xml codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">io.swagger.core.v3</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">swagger-annotations</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre><p>But this will not work. This dependency is not binary compatible with Swagger v2 annotations. The resulting code will fail to compile.</p><p>As alternative instead use the following dependency:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-xml codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">io.swagger.parser.v3</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"><</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain">swagger-parser</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span><span class="token plain"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)"></</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">></span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre><h2><a aria-hidden="true" tabindex="-1" class="anchor" id="gradle"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#gradle" title="Direct link to heading">#</a>Gradle</h2><p>This gradle plugin offers a declarative DSL via extensions (these are Gradle project extensions). These map almost fully 1:1 with the options you’d pass to the CLI or Maven plugin. The plugin maps the extensions to a task of the same name to provide a clean API. If you’re interested in the extension/task mapping concept from a high-level, you can check out <a href="https://docs.gradle.org/current/userguide/custom_plugins.html#sec:mapping_extension_properties_to_task_properties">Gradle’s docs</a>.</p><p>To include in your project, add the following to <code>build.gradle</code>:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-groovy codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token plain">buildscript {</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> repositories {</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> mavenLocal()</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> maven { url "https://repo1.maven.org/maven2" }</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> }</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> dependencies {</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> classpath "org.openapitools:openapi-generator-gradle-plugin:5.0.0"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> }</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain">}</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain">apply plugin: 'org.openapi.generator'</span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre><p>This gives access to the following tasks:</p><table><thead><tr><th>Task</th><th>Description</th></tr></thead><tbody><tr><td>openApiGenerate</td><td>Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents.</td></tr><tr><td>openApiGenerators</td><td>Lists generators available via Open API Generators.</td></tr><tr><td>openApiMeta</td><td>Generates a new generator to be consumed via Open API Generator.</td></tr><tr><td>openApiValidate</td><td>Validates an Open API 2.0 or 3.x specification document.</td></tr></tbody></table><blockquote><p>The plugin implements the above tasks as project extensions of the same name. If you’d like to declare these tasks as dependencies to other tasks (using <code>dependsOn</code>), you’ll need a task reference. e.g.:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-groovy codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token plain">compileJava.dependsOn tasks.openApiGenerate</span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre></blockquote><p>For full details of all options, see the <a href="https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin">plugin README</a>.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor" id="example-1"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#example-1" title="Direct link to heading">#</a>Example</h3><p>An example task for generating a kotlin client:</p><pre class="mdxCodeBlock_iHAB"><div class="codeBlockWrapper_2QGZ"><pre class="prism-code language-groovy codeBlock_19pQ" style="color:#F8F8F2;background-color:#282A36"><div class="token-line" style="color:#F8F8F2"><span class="token plain">openApiGenerate {</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> generatorName = "kotlin"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> inputSpec = "$rootDir/specs/petstore-v3.0.yaml".toString()</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> outputDir = "$buildDir/generated".toString()</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> apiPackage = "org.openapi.example.api"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> invokerPackage = "org.openapi.example.invoker"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> modelPackage = "org.openapi.example.model"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> configOptions = [</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> dateLibrary: "java8"</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain"> ]</span></div><div class="token-line" style="color:#F8F8F2"><span class="token plain">}</span></div></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_1BYj">Copy</button></div></pre></div></article><div class="margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/OpenAPITools/openapi-generator/edit/master/website/../docs/plugins.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col text--right"><em><small>Last updated on <time datetime="2021-11-20T17:25:45.000Z" class="docLastUpdatedAt_1sqk">2021-11-20</time> by <strong>Kevin Chen</strong></small></em></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/installation"><h5 class="pagination-nav__link--sublabel">Previous</h5><h4 class="pagination-nav__link--label">« CLI Installation</h4></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/online"><h5 class="pagination-nav__link--sublabel">Next</h5><h4 class="pagination-nav__link--label">Online »</h4></a></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_TbNY"><ul class="contents contents__left-border"><li><a href="#maven" class="contents__link">Maven</a><ul><li><a href="#example" class="contents__link">Example</a></li><li><a href="#dependencies" class="contents__link">Dependencies</a></li></ul></li><li><a href="#gradle" class="contents__link">Gradle</a><ul><li><a href="#example-1" class="contents__link">Example</a></li></ul></li></ul></div></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/customization">Customizing Generators</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/installation">Installation</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/integrations">Workflow Integrations</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/users">User Showcase</a></li><li class="footer__item"><a class="footer__link-item" target="_blank" rel="noopener noreferrer" href="https://stackoverflow.com/questions/tagged/openapi-generator">Stack Overflow</a></li><li class="footer__item"><a class="footer__link-item" target="_blank" rel="noopener noreferrer" href="https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM">Chat Room</a></li><li class="footer__item"><a class="footer__link-item" target="_blank" rel="noopener noreferrer" href="https://twitter.com/oas_generator">Twitter</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">More</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/blog">Blog</a></li><li class="footer__item"><a class="footer__link-item" target="_blank" rel="noopener noreferrer" href="https://github.com/OpenAPITools/openapi-generator">GitHub</a></li></ul></div></div><div class="text--center"><div class="margin-bottom--sm"><a href="https://openapi-generator.tech/" target="_blank" rel="noopener noreferrer" class="footerLogoLink_1Wg7"><img class="footer__logo" alt="OpenAPI Tools" src="/img/mono-logo.svg"></a></div>Copyright © 2021 OpenAPI-Generator Contributors (https://openapi-generator.tech)</div></div></footer>
|
||
</div>
|
||
|
||
<script src="/styles.38be54b8.js"></script>
|
||
|
||
<script src="/runtime~main.f7c11631.js"></script>
|
||
|
||
<script src="/main.a437a66b.js"></script>
|
||
|
||
<script src="/1.df107477.js"></script>
|
||
|
||
<script src="/2.575ca174.js"></script>
|
||
|
||
<script src="/3.eada3617.js"></script>
|
||
|
||
<script src="/1be78505.3e977af1.js"></script>
|
||
|
||
<script src="/20ac7829.be2ad927.js"></script>
|
||
|
||
<script src="/17896441.60782a44.js"></script>
|
||
|
||
<script src="/e360e27f.46622e59.js"></script>
|
||
|
||
|
||
</body>
|
||
</html> |