or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdcore-generation.mdindex.mdmodel-system.mdutilities.mdvalidation.md
tile.json

tessl/maven-org-openapitools--openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.openapitools/openapi-generator@7.14.x

To install, run

npx @tessl/cli install tessl/maven-org-openapitools--openapi-generator@7.14.0

index.mddocs/

OpenAPI Generator

OpenAPI Generator is a comprehensive code generation framework that automatically creates API client libraries, server stubs, documentation, and configuration files from OpenAPI Specification documents (versions 2.0 and 3.0). It provides extensive customization through templates and configuration, supporting over 50 programming languages and frameworks.

Package Information

  • Package Name: openapi-generator
  • Package Type: maven
  • Language: Java
  • Installation: <dependency><groupId>org.openapitools</groupId><artifactId>openapi-generator</artifactId><version>7.14.0</version></dependency>

Core Imports

import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;

Basic Usage

import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.config.CodegenConfigurator;

// Configure the generator
CodegenConfigurator configurator = new CodegenConfigurator()
    .setGeneratorName("java")
    .setInputSpec("https://petstore.swagger.io/v2/swagger.json")
    .setOutputDir("./generated-code");

// Generate the code
DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(configurator.toClientOptInput()).generate();

Architecture

OpenAPI Generator is built around several key components:

  • CodegenConfig Interface: Defines the contract for code generation configuration and customization
  • Generator Implementation: Executes the generation process using configured settings
  • Model System: Represents OpenAPI schemas as Java objects for template processing
  • Template Engine: Processes Mustache/Handlebars templates with model data
  • Language Generators: 50+ specific implementations for different programming languages
  • Configuration System: Flexible option handling and customization framework

Capabilities

Core Code Generation

Primary interfaces and classes for setting up and executing code generation workflows. Essential for creating custom generators and configuring generation processes.

interface CodegenConfig {
    String getName();
    CodegenType getTag();
    GeneratorLanguage generatorLanguage();
    
    // Model and operation conversion
    CodegenModel fromModel(String name, Schema schema);
    CodegenOperation fromOperation(String resourcePath, String httpMethod, 
                                   Operation operation, List<Server> servers);
    
    // Post-processing
    Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs);
    OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels);
}

interface Generator {
    Generator opts(ClientOptInput opts);
    List<File> generate();
}

Core Generation

Configuration Management

Configuration classes and builders for setting up generation parameters, including input specifications, output directories, and generator options.

class CodegenConfigurator {
    public static CodegenConfigurator fromFile(String configFile, Module... modules);
    
    public CodegenConfigurator setGeneratorName(String generatorName);
    public CodegenConfigurator setInputSpec(String inputSpec);
    public CodegenConfigurator setOutputDir(String outputDir);
    public CodegenConfigurator addAdditionalProperty(String key, Object value);
    
    public ClientOptInput toClientOptInput();
}

class ClientOptInput {
    public ClientOptInput openAPI(OpenAPI openAPI);
    public ClientOptInput config(CodegenConfig codegenConfig);
}

Configuration Management

Model System

Classes representing OpenAPI schemas, operations, parameters, and responses as Java objects for template processing and code generation.

class CodegenModel implements IJsonSchemaValidationProperties {
    public String name;              // Schema name
    public String classname;         // Generated class name
    public String description;       // Model description
    public List<CodegenProperty> vars;         // Model properties
    public List<CodegenProperty> requiredVars; // Required properties
    public String parent;            // Parent class name
    public List<String> interfaces;  // Implemented interfaces
}

class CodegenOperation {
    public String path;              // URL path
    public String operationId;       // Operation identifier
    public String httpMethod;        // HTTP method
    public String nickname;          // Generated method name
    public List<CodegenParameter> allParams;   // All parameters
    public List<CodegenResponse> responses;    // Response definitions
    public String returnType;        // Return type
}

Model System

Validation Framework

JSON Schema validation properties and type checking utilities for ensuring proper data handling and constraint validation.

interface IJsonSchemaValidationProperties {
    // Type identification
    boolean getIsModel();
    boolean getIsArray();
    boolean getIsString();
    boolean getIsNumber();
    
    // Validation constraints
    String getPattern();
    String getMinimum();
    String getMaximum();
    Integer getMinLength();
    Integer getMaxLength();
    
    // Schema relationships
    CodegenProperty getItems();
    List<CodegenProperty> getVars();
}

Validation Framework

Utility Functions

Helper classes and utilities for schema analysis, string manipulation, version handling, and model processing.

class ModelUtils {
    public static boolean isObjectSchema(Schema schema);
    public static boolean isArraySchema(Schema schema);
    public static boolean isStringSchema(Schema schema);
    public static List<String> getAllUsedSchemas(OpenAPI openAPI);
    public static Schema unaliasSchema(Schema schema, OpenAPI openAPI);
}

class StringUtils {
    public static String camelize(String word);
    public static String underscore(String word);
    public static String dashize(String word);
}

Utility Functions

Common Types

enum CodegenType {
    CLIENT,          // Client library generation
    SERVER,          // Server stub generation  
    DOCUMENTATION,   // Documentation generation
    SCHEMA,          // Schema-only generation
    CONFIG,          // Configuration file generation
    OTHER            // Other/custom generation types
}

enum GeneratorLanguage {
    JAVA, PYTHON, JAVASCRIPT, TYPESCRIPT, C_SHARP, GO, RUBY, PHP, 
    SWIFT, KOTLIN, SCALA, C_PLUS_PLUS, RUST, // ... 50+ languages
}

class SpecValidationException extends RuntimeException {
    public Set<String> getErrors();
    public Set<String> getWarnings();
}