I would like to define a requestBody that simply resolves to a kotlin.Pair when generated. I tried the following but with no luck:

  required: true
        type: object
            type: string
            type: string

Can it be done and if so, how?

To generate Kotlin Pair classes using OpenAPI Generator, you’ll first need to define your OpenAPI (formerly known as Swagger) specification file. OpenAPI Generator allows you to generate client libraries, server stubs, API documentation, and other artifacts based on your OpenAPI specification.

Here’s a step-by-step guide to generating Kotlin Pair classes using OpenAPI Generator:

Install OpenAPI Generator:
Make sure you have OpenAPI Generator installed on your system. You can install it using package managers like npm, Homebrew, or by downloading the JAR file directly.

Write or Obtain OpenAPI Specification:
Create or obtain an OpenAPI Specification file (usually in YAML or JSON format) that describes your API. This file should contain definitions for the data structures used in your API, including any Pair classes you want to generate.

Generate Kotlin Code:
Run the OpenAPI Generator CLI command with the appropriate options to generate Kotlin code. Specify the language (kotlin) and the path to your OpenAPI specification file.

For example, using the command line:


openapi-generator generate -i your_openapi_spec.yaml -g kotlin -o output_directory

Configure Pair Classes:
Ensure that your OpenAPI specification includes definitions for the Pair classes you want to generate. You can define them in the definitions section of your specification file using the type: object keyword.

For example:


    type: object
        type: string
        type: integer

Adjust the properties and types according to your requirements.

Customize Output:
Optionally, you can customize the output by modifying the OpenAPI specification, adjusting generator options, or providing templates. OpenAPI Generator provides various options for customization, such as package names, file naming conventions, and code formatting.

Generate Code:
Run the OpenAPI Generator command again to generate the Kotlin code with the specified changes.

Use Generated Classes:
Once the code generation process is complete, you’ll find the generated Kotlin classes in the output directory you specified. You can import and use these classes in your Kotlin project as needed.