Skip to main content

Code Generation

Based on API definitions, Apidog supports automatic generation of business code for various languages and frameworks, including but not limited to TypeScript, Java, Go, Swift, ObjectiveC, Kotlin, Dart, C++, C#, Rust and other 130 languages and frameworks.

Auto-generated business code includes Model, Controller, unit test code, and so on. Standard-compliant API request code can be quickly generated in the API design page without manual writing, ensuring that the generated code is consistent with the API model definition.

Not only that, but you can also use the Custom Code Templates feature to generate code that conforms to your team's architectural specifications to meet a variety of individual needs.

info

The features of Apidog's code templates are based on OpenAPI Generator but have been further simplified. You can refer to this Youtube Video to learn more about the rules of OpenAPI generator templates.

Generate API request code

API request code is used to initiate API requests in various development environments. Click the Generate API Request Code button on the right side of the Documentation tab in the API.

You can also generate code by clicking the code icon in the Run tab in the API.

Code generation can also be quickly in the API.

You can quickly select code from different environments in the code generation page.

Generate Client Code

Client code refers to the source code that implements a business logic, is one of the most important components of a system, usually runs on a server, and is responsible for implementing business requirements, data processing, and logic control.

Prerequisites

1. Apidog plugin

2. Java environment

Before exporting business code, the plug-in must be installed on the machine. Click the "Download and Install" button in the business code generation page.

After downloading, select the desired server-side business code.

Generate the data model code

Data model code is used to define schemas, and is commonly used for serialization when APIs send data and deserialization processing when data is received. After the SQL code type is generated, you can also define table creation statements in the database table creation scenario to create data tables in the database.

To access the data model, tap the Generate Code option in the model page.

Model code supports multiple code types.

Full list of code types:

C#C++CrystalDartElmFlow
GoHaskellJavaJavaScriptKotlinObjective-C
PikePythonRubyRustSQLSwift
TypeScript

SQL table creation statement

Supports rapid generation of data model code, including SQL table creation statements. Click the "Generate Code" button and select the SQL code type to view the table creation statement.