{"id":127900,"date":"2024-11-01T11:04:54","date_gmt":"2024-11-01T09:04:54","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=127900"},"modified":"2024-10-31T11:10:00","modified_gmt":"2024-10-31T09:10:00","slug":"openapi-custom-generator","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html","title":{"rendered":"OpenAPI Custom Generator"},"content":{"rendered":"<p>OpenAPI is a powerful tool for generating code from API specifications, but sometimes, default generators do not meet specific project needs. Let us delve into understanding the creation of a Java OpenAPI custom generator.<\/p>\n<h2><a name=\"section-1\"><\/a>1. Introduction<\/h2>\n<p>The <a href=\"https:\/\/spec.openapis.org\/oas\/latest.html\" target=\"_blank\" rel=\"noopener\">OpenAPI Specification<\/a> is a standardized format widely used for defining and documenting RESTful APIs, ensuring consistency and ease of use across different platforms and languages. To facilitate the development process, the OpenAPI Generator is a tool that enables developers to generate various assets directly from an API specification, such as client SDKs, server stubs, and documentation. By taking an OpenAPI Specification document as input, the OpenAPI Generator can automatically create these assets, significantly reducing development time and minimizing manual coding errors.<\/p>\n<p>The OpenAPI Generator comes with a wide range of built-in generators that support multiple programming languages and frameworks. These built-in generators allow developers to quickly generate client libraries and server implementations in languages such as Java, Python, JavaScript, and more, helping them integrate APIs efficiently into their applications. Additionally, the OpenAPI Generator can produce comprehensive documentation in formats like HTML and Markdown, making it easier to share and understand API details.<\/p>\n<p>Despite the versatility of these built-in generators, certain projects may have unique requirements that are not fully addressed by the default configurations. In such cases, developers can create a custom generator. A custom generator allows developers to define specific templates and settings that tailor the generated output to the particular needs of their project, such as adding custom file structures, and templates, or even modifying the default behavior of the generator. By extending or modifying the OpenAPI Generator, developers can produce assets that align more closely with their project\u2019s standards, ensuring compatibility and enhancing maintainability.<\/p>\n<h3>1.1 Why Create a New Generator?<\/h3>\n<p>Creating a new <a href=\"https:\/\/openapi-generator.tech\/\" target=\"_blank\" rel=\"noopener\">OpenAPI Generator<\/a> provides significant advantages, particularly when standard generators don\u2019t fully meet the specific needs of a project. Custom generators allow developers to go beyond what is available out of the box and create API assets that are more closely aligned with project requirements.<\/p>\n<ul>\n<li>Customization: A custom OpenAPI generator offers the ability to produce code that aligns with specific coding standards, organizational preferences, and the overall structure of the project. By creating a tailored generator, developers can incorporate naming conventions, file structures, and annotations that fit seamlessly into their existing codebase. This customization can improve maintainability and make the generated code more compatible with other parts of the project.<\/li>\n<li>Additional Features: Custom generators allow for adding unique features or documentation that the default OpenAPI generators may not support. For instance, developers require additional data validations, specific exception-handling mechanisms, or support for custom authentication methods within the generated code. A custom generator makes it possible to include such enhancements, delivering assets that fully reflect the API\u2019s functionality and design. Developers can also customize generated documentation to include more project-specific instructions, usage examples, or visual aids, improving clarity and usability for end-users.<\/li>\n<li>Enhanced Output: A custom generator can modify the output format to improve readability or ensure compatibility with additional tools and services. This includes altering indentation, line breaks, and general layout, which can make the code easier to review and integrate into the development workflow. Additionally, custom formatting options can make the generated assets compatible with tools for version control, deployment pipelines, or specific IDEs, thereby streamlining collaboration and deployment processes.<\/li>\n<\/ul>\n<p>Overall, building a custom OpenAPI generator allows teams to create optimized, standards-compliant, and feature-rich assets that integrate seamlessly with their project\u2019s ecosystem, making it a valuable approach for more complex or specialized API requirements.<\/p>\n<h3>1.2 Benefits of OpenAPI Generator<\/h3>\n<ul>\n<li>Increased Development Efficiency: Automates the creation of API client SDKs, server stubs, and documentation, reducing repetitive coding tasks.<\/li>\n<li>Consistency Across Codebases: Ensures that all API clients, server stubs, and documentation align with the latest API specification, improving consistency across projects.<\/li>\n<li>Language and Framework Flexibility: Supports multiple languages and frameworks, making it versatile for diverse development environments.<\/li>\n<li>Rapid Prototyping: Enables quick API prototyping by generating server and client code directly from specifications, helping developers test and iterate faster.<\/li>\n<li>Enhanced Documentation: Generates detailed API documentation based on the OpenAPI spec, improving API transparency and accessibility for users.<\/li>\n<li>Standardization of APIs: Facilitates API standardization across teams by using a unified specification and generation tool, ensuring consistency and maintainability.<\/li>\n<li>Customizability: Allows custom generators and templates to meet unique project needs, making them adaptable to different coding standards and architectural styles.<\/li>\n<\/ul>\n<h3>1.3 Use Cases for OpenAPI Generator<\/h3>\n<ul>\n<li>Client SDK Generation: Automatically create client libraries in multiple languages (e.g., Java, Python, JavaScript) to enable faster and more consistent API consumption.<\/li>\n<li>Server Stub Generation: Generate server stubs to quickly set up backend endpoints and serve as a foundation for implementing business logic.<\/li>\n<li>Microservices Development: Facilitate microservices communication by generating API clients and ensuring all services interact consistently.<\/li>\n<li>API Documentation: Automatically generate interactive API documentation, such as HTML docs or Markdown files, to improve API usability.<\/li>\n<li>Testing API Endpoints: Use generated clients and mocks for API testing to ensure endpoints function as expected before release.<\/li>\n<li>API Versioning and Maintenance: Update and regenerate code for different API versions to handle changes with minimal manual effort.<\/li>\n<li>Rapid Prototyping for MVPs: Quickly prototype and test Minimum Viable Products (MVPs) by generating code from the API spec for faster iterations.<\/li>\n<\/ul>\n<h2><a name=\"section-2\"><\/a>2. Creating an OpenAPI Generator Project<\/h2>\n<p>Setting up a new generator project involves creating a Maven or Gradle project and configuring it to work with the OpenAPI Generator\u2019s codebase. Below is a step-by-step guide:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3>2.1 Add Dependencies<\/h3>\n<p>Add the necessary dependencies to the <code>pom.xml<\/code> file:<\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;dependencies&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.openapitools&lt;\/groupId&gt;\n        &lt;artifactId&gt;openapi-generator&lt;\/artifactId&gt;\n        &lt;version&gt;your_jar_version&lt;\/version&gt;\n    &lt;\/dependency&gt;\n&lt;\/dependencies&gt;\n<\/pre>\n<h3>2.2 Implementing the Generator<\/h3>\n<h4>2.2.1 Creating a Generator class<\/h4>\n<p>OpenAPI generators extend from the <code>AbstractJavaCodegen<\/code> class or other base classes provided by the OpenAPI Generator library. Let&#8217;s understand the generator class below.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.example.generator;\n\nimport org.openapitools.codegen.languages.AbstractJavaCodegen;\nimport org.openapitools.codegen.CodegenConfig;\n\npublic class MyCustomGenerator extends AbstractJavaCodegen implements CodegenConfig {\n\n    public MyCustomGenerator() {\n        super();\n        outputFolder = \"generated-code\/my-custom-generator\";\n        modelTemplateFiles.put(\"model.mustache\", \".java\");\n    }\n\n    @Override\n    public String getName() {\n        return \"my-custom-generator\";\n    }\n\n    @Override\n    public void processOpts() {\n        super.processOpts();\n        apiTemplateFiles.put(\"api.mustache\", \".java\");\n        supportingFiles.add(new SupportingFile(\"README.mustache\", \"\", \"README.md\"));\n    }\n}\n<\/pre>\n<h5>2.2.1.1 Code explanation<\/h5>\n<p>The code defines a custom generator in Java, named <code>MyCustomGenerator<\/code>, which extends the <code>AbstractJavaCodegen<\/code> class and implements the <code>CodegenConfig<\/code> interface from the OpenAPI tools library.<\/p>\n<ul>\n<li>In the constructor <code>MyCustomGenerator()<\/code>, the superclass&#8217;s constructor is called with <code>super()<\/code>. The <code>outputFolder<\/code> is set to <code>\"generated-code\/my-custom-generator\"<\/code>, which specifies the directory where the generated files will be stored.<\/li>\n<li>A model template is added by mapping <code>\"model.mustache\"<\/code> files to generate <code>.java<\/code> files.<\/li>\n<li>The <code>getName()<\/code> method returns the name of the generator, <code>\"my-custom-generator\"<\/code>. This is used by OpenAPI tools to recognize the generator.<\/li>\n<li>The <code>processOpts()<\/code> method, which handles additional processing options, is overridden. It first calls the superclass\u2019s method, then maps <code>\"api.mustache\"<\/code> templates to <code>.java<\/code> files and adds a supporting file, <code>README.md<\/code>, generated from the <code>\"README.mustache\"<\/code> template.<\/li>\n<\/ul>\n<p>This generator customizes the code generation process for OpenAPI specifications.<\/p>\n<h4>2.2.2 Creating a Mustache template<\/h4>\n<p><a href=\"https:\/\/mustache.github.io\/\" target=\"_blank\" rel=\"noopener\">Mustache templates<\/a> define how the generated code will be structured. A basic <code>model.mustache<\/code> template look like this:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">package {{package}};\n\npublic class {{classname}} {\n    {{#vars}}\n    private {{datatype}} {{name}};\n    {{\/vars}}\n}\n<\/pre>\n<p>Place this template in the templates folder within your project.<\/p>\n<h5>2.2.2.1 Code explanation<\/h5>\n<p>The template provided is used to generate Java classes based on an OpenAPI specification. This template is used within the OpenAPI Generator to create Java model classes dynamically by substituting the placeholders with values from the OpenAPI specification.<\/p>\n<ul>\n<li>{{package}}:\n<ul>\n<li>This placeholder is replaced by the package name defined in the OpenAPI configuration or input.<\/li>\n<li>It ensures that each generated class is placed in the correct package namespace.<\/li>\n<\/ul>\n<\/li>\n<li>{{classname}}:\n<ul>\n<li>This placeholder is replaced by the name of the class generated for a specific model defined in the OpenAPI specification.<\/li>\n<li>For example, if the model is <code>User<\/code>, <code>{{classname}}<\/code> will be replaced with <code>User<\/code>.<\/li>\n<\/ul>\n<\/li>\n<li>{{#vars}} and {{\/vars}}:\n<ul>\n<li><code>{{#vars}}<\/code> starts a loop over a list of properties (or variables) within the class, and <code>{{\/vars}}<\/code> ends this loop.<\/li>\n<li>Each <code>vars<\/code> item represents an attribute (e.g., a field of a model) defined in the OpenAPI spec, such as <code>id<\/code>, <code>name<\/code>, or <code>email<\/code> in a <code>User<\/code> class.<\/li>\n<\/ul>\n<\/li>\n<li>{{datatype}}:\n<ul>\n<li>This placeholder within the loop represents the data type of each variable, such as <code>String<\/code>, <code>int<\/code>, or <code>boolean<\/code>, based on the OpenAPI specification\u2019s type definitions.<\/li>\n<li>For instance, if <code>name<\/code> is defined as a string type, <code>{{datatype}}<\/code> will be replaced with <code>String<\/code>.<\/li>\n<\/ul>\n<\/li>\n<li>{{name}}:\n<ul>\n<li>This placeholder represents the actual name of the variable within the class.<\/li>\n<li>For example, in the <code>User<\/code> model, the <code>name<\/code> attribute will be used to generate <code>private String name;<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2><a name=\"section-3\"><\/a>3. Unit Testing<\/h2>\n<p>Unit testing is crucial for validating the logic within your generator. Using <a href=\"https:\/\/junit.org\/junit5\/\" target=\"_blank\" rel=\"noopener\">JUnit<\/a>, we can verify the correctness of the generator&#8217;s behavior.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.example.generator;\n\nimport org.junit.jupiter.api.Test;\nimport org.openapitools.codegen.SupportingFile;\n\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class MyCustomGeneratorTest {\n\n    @Test\n    public void testGeneratorName() {\n        MyCustomGenerator generator = new MyCustomGenerator();\n        assertEquals(\"my-custom-generator\", generator.getName());\n    }\n\n    @Test\n    public void testOutputFolder() {\n        MyCustomGenerator generator = new MyCustomGenerator();\n        assertTrue(generator.outputFolder.contains(\"my-custom-generator\"));\n    }\n\n    @Test\n    public void testProcessOpts() {\n        MyCustomGenerator generator = new MyCustomGenerator();\n        generator.processOpts();\n\n        \/\/ Check that the model template file is set correctly\n        assertTrue(generator.modelTemplateFiles.containsKey(\"model.mustache\"));\n        assertEquals(\".java\", generator.modelTemplateFiles.get(\"model.mustache\"));\n\n        \/\/ Check that the api template file is set correctly\n        assertTrue(generator.apiTemplateFiles.containsKey(\"api.mustache\"));\n        assertEquals(\".java\", generator.apiTemplateFiles.get(\"api.mustache\"));\n\n        \/\/ Check that supporting files contain README.md\n        assertTrue(generator.supportingFiles.stream().anyMatch(\n                file -&gt; file.destinationFilename.equals(\"README.md\")\n        ));\n    }\n}\n<\/pre>\n<p>The code defines a test class named <code>MyCustomGeneratorTest<\/code>, which tests the behavior of the <code>MyCustomGenerator<\/code> class. It is part of the <code>com.example.generator<\/code> package and uses the JUnit 5 testing framework, imported with <code>org.junit.jupiter.api.Test<\/code> and <code>org.junit.jupiter.api.Assertions.*<\/code>, to validate specific aspects of the <code>MyCustomGenerator<\/code> implementation.<\/p>\n<ul>\n<li>The <code>testGeneratorName<\/code> method creates an instance of <code>MyCustomGenerator<\/code> and verifies that the generator\u2019s name is set correctly. The method calls <code>generator.getName()<\/code> and uses <code>assertEquals<\/code> to confirm that it returns <code>\"my-custom-generator\"<\/code>, as expected.<\/li>\n<li>The <code>testOutputFolder<\/code> method also creates an instance of <code>MyCustomGenerator<\/code> and checks if the <code>outputFolder<\/code> variable contains the expected value, <code>\"my-custom-generator\"<\/code>. It uses <code>assertTrue<\/code> to validate that the <code>outputFolder<\/code> path includes this string, confirming that the output folder is configured correctly.<\/li>\n<li><code>testProcessOpts<\/code>: This new test case verifies the configurations that processOpts sets up:\n<ul>\n<li>It confirms that the modelTemplateFiles and apiTemplateFiles contain the right entries (&#8220;model.mustache&#8221; and &#8220;api.mustache&#8221; mapped to .java).<\/li>\n<li>It also checks that supportingFiles includes the README file.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Together, these test methods ensure that the <code>MyCustomGenerator<\/code> class has the correct name and output folder settings, providing basic verification for key configurations of the generator. Running these tests will result in an output indicating whether each assertion passes or fails.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">[INFO] Running MyCustomGeneratorTest\n[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.123 s\n[INFO] All tests passed.\n<\/pre>\n<h2><a name=\"section-4\"><\/a>4. Integration Test<\/h2>\n<p>Integration tests ensure that your custom generator works seamlessly with OpenAPI specifications. Below is a test setup that uses an example OpenAPI specification to generate code.<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.example.generator;\n\nimport org.junit.jupiter.api.Test;\nimport org.openapitools.codegen.ClientOptInput;\nimport org.openapitools.codegen.DefaultGenerator;\nimport org.openapitools.codegen.config.CodegenConfigurator;\n\nimport static org.junit.jupiter.api.Assertions.assertTrue;\nimport java.io.File;\n\npublic class MyCustomGeneratorIntegrationTest {\n\n    @Test\n    public void testGenerateCodeFromSpec() {\n        \/\/ \"example.yaml\" is an OpenAPI specification file located in src\/test\/resources.\n        \/\/ It defines the API endpoints, data models, and responses according to the OpenAPI standard.\n        \/\/ This file provides the blueprint for generating the API client\/server code with the custom generator.\n        CodegenConfigurator configurator = new CodegenConfigurator()\n            .setGeneratorName(\"my-custom-generator\")\n            .setInputSpec(\"src\/test\/resources\/example.yaml\")\n            .setOutputDir(\"out\/my-custom-generator\");\n\n        \/\/ Converts configuration into the input format for code generation\n        ClientOptInput input = configurator.toClientOptInput();\n        DefaultGenerator generator = new DefaultGenerator();\n\n        \/\/ Runs the generator with the provided specification, generating code in the output directory\n        generator.opts(input).generate();\n\n        \/\/ Verification: Check if output directory contains generated files\n        File outputDir = new File(\"out\/my-custom-generator\");\n        assertTrue(outputDir.exists() &amp;&amp; outputDir.isDirectory(), \"Output directory should exist and contain generated files.\");\n    }\n}\n<\/pre>\n<p>Run the test and verify that the generated output in <code>out\/my-custom-generator<\/code> matches your custom template\u2019s specifications. Make note that the <code>example.yaml<\/code> file will depend on your business requirements.<\/p>\n<p>Below is the <code>example.yaml<\/code> file used for this article:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">openapi: 3.0.0\ninfo:\n  title: Sample API\n  version: 1.0.0\n  description: A simple API for demonstrating OpenAPI code generation with custom settings.\n\npaths:\n  \/items:\n    get:\n      summary: Retrieve a list of items\n      operationId: getItems\n      responses:\n        '200':\n          description: A list of items.\n          content:\n            application\/json:\n              schema:\n                type: array\n                items:\n                  $ref: '#\/components\/schemas\/Item'\n    post:\n      summary: Create a new item\n      operationId: createItem\n      requestBody:\n        description: Details of the item to create\n        required: true\n        content:\n          application\/json:\n            schema:\n              $ref: '#\/components\/schemas\/Item'\n      responses:\n        '201':\n          description: Item created successfully.\n        '400':\n          description: Invalid input.\n\n  \/items\/{itemId}:\n    get:\n      summary: Get details of a specific item\n      operationId: getItemById\n      parameters:\n        - name: itemId\n          in: path\n          required: true\n          schema:\n            type: integer\n            example: 1\n      responses:\n        '200':\n          description: Details of the specified item.\n          content:\n            application\/json:\n              schema:\n                $ref: '#\/components\/schemas\/Item'\n        '404':\n          description: Item not found.\n\ncomponents:\n  schemas:\n    Item:\n      type: object\n      required:\n        - id\n        - name\n      properties:\n        id:\n          type: integer\n          example: 1\n        name:\n          type: string\n          example: \"Sample Item\"\n        description:\n          type: string\n          example: \"This is a sample item.\"\n        price:\n          type: number\n          format: float\n          example: 19.99\n<\/pre>\n<p>Since this test checks that the output directory is created, the result will indicate whether code generation was successful. If the output directory exists and contains generated files, the assertion will pass; otherwise, it will fail.<\/p>\n<h2><a name=\"section-5\"><\/a>5. Using the Custom Generator<\/h2>\n<p>Run the custom generator from the command line with:<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">java -jar openapi-generator-cli.jar generate \\\n    -g my-custom-generator \\\n    -i \/path\/to\/openapi.yaml \\\n    -o \/path\/to\/output\n<\/pre>\n<p>This command applies your custom generator to the specified OpenAPI specification file.<\/p>\n<h2><a name=\"section-6\"><\/a>6. Conclusion<\/h2>\n<p>Creating a custom OpenAPI generator allows you to fully control the structure and design of the generated code. With the ability to customize templates, add new configurations, and create tests, you can integrate the generator seamlessly into your development workflow. This approach helps meet specific project requirements and ensures that the generated code adheres to your team\u2019s coding standards.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenAPI is a powerful tool for generating code from API specifications, but sometimes, default generators do not meet specific project needs. Let us delve into understanding the creation of a Java OpenAPI custom generator. 1. Introduction The OpenAPI Specification is a standardized format widely used for defining and documenting RESTful APIs, ensuring consistency and ease &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[1200,2034],"class_list":["post-127900","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-java","tag-openapi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OpenAPI Custom Generator - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OpenAPI Custom Generator - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:04:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"OpenAPI Custom Generator\",\"datePublished\":\"2024-11-01T09:04:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html\"},\"wordCount\":1687,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"Java\",\"OpenAPI\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html\",\"name\":\"OpenAPI Custom Generator - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2024-11-01T09:04:54+00:00\",\"description\":\"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/openapi-custom-generator.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"OpenAPI Custom Generator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OpenAPI Custom Generator - Java Code Geeks","description":"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html","og_locale":"en_US","og_type":"article","og_title":"OpenAPI Custom Generator - Java Code Geeks","og_description":"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.","og_url":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2024-11-01T09:04:54+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"OpenAPI Custom Generator","datePublished":"2024-11-01T09:04:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html"},"wordCount":1687,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["Java","OpenAPI"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html","url":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html","name":"OpenAPI Custom Generator - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2024-11-01T09:04:54+00:00","description":"Java openapi custom generator: Learn how to create a custom OpenAPI generator in Java for tailored API client generation.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/openapi-custom-generator.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"OpenAPI Custom Generator"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=127900"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127900\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=127900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=127900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=127900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}