You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The XAP (Expedia API Platform) SDK is structured as a multi-module Gradle project designed to generate a Kotlin/Java SDK from OpenAPI specifications. The architecture follows a code generation approach, where API client code is automatically generated and then published to repositories for consumption by developers.
3
+
The XAP (Expedia API Platform) SDK is structured as a multi-module Gradle project designed to generate a Kotlin/Java SDK
4
+
from OpenAPI specifications. The architecture follows a code generation approach, where API client code is automatically
5
+
generated and then published to repositories for consumption by developers.
4
6
5
7
The repository contains the following key components:
|`mergeSpecs`| Executes the openapi-merge-cli command using npx to merge OpenAPI specs. |
53
+
|`transformSpecs`| Executes the spec-transformer CLI command using npx to transform the OpenAPI specs. |
54
+
|`prepareSpecs`| A wrapper for the sequential execution of `mergeSpecs` and `transformSpecs`. Generates and copies a final specs.yaml file to the generator module's resources directory |
55
+
56
+
## Generator Module
57
+
58
+
The `generator` module is responsible for the core functionality of the SDK generation process. It consumes the OpenAPI
59
+
specifications and generates the initial SDK code using OpenAPI Generator. It also integrates with the
60
+
`expediagroup-sdk-openapi-plugin`.
38
61
39
-
The `generator` module is responsible for the core functionality of the SDK generation process. It consumes the OpenAPI specifications and generates the initial SDK code using OpenAPI Generator. It also integrates with the`expediagroup-sdk-openapi-plugin`.
|**OpenAPI Generator Configurations**| The core library that generates the SDK code from OpenAPI specifications. Lives in the `build.gradle.kts` file. |
65
+
|**Custom Templates**| Custom templates for generating Kotlin/Java code. Lives in the `src/main/resources/templates` directory. |
66
+
|**Post-Processing**| Enhancements and optimizations applied to the generated code. Lives in the `src/main/resources/post-processing` directory. |
|**OpenAPI Generator Configurations**| The core library that generates the SDK code from OpenAPI specifications. Lives in the `build.gradle.kts` file |
44
-
|**Custom Templates**| Custom templates for generating Kotlin/Java code. Lives in the `src/main/resources/templates` directory |
45
-
|**Post-Processing**| Enhancements and optimizations applied to the generated code. Lives in the `src/main/resources/post-processing` directory |
68
+
The generation process can be executed through the `openApiGenerate` Gradle task, which triggers the OpenAPI Generator
69
+
with the specified configurations.
46
70
47
-
The generation process can be executed through the `openApiGenerate` Gradle task, which triggers the OpenAPI Generator with the specified configurations.
48
71
```shell
49
72
gradle clean build
50
73
51
74
cd generator
52
75
gradle openApiGenerate --stacktrace
53
76
```
77
+
54
78
The `openApiGenerate` gradle task workflow is as follows:
55
-
1. Locates the OpenAPI specification file through the `inputSpec` environment variable, falling back to `generator/src/main/resources/specs.yaml` if not found.
79
+
80
+
1. Locates the OpenAPI specification file through the `inputSpec` environment variable, falling back to
81
+
`generator/src/main/resources/specs.yaml` if not found.
56
82
2. Consumes the OpenAPI specification file to generates code into the `xap-sdk/src/main/kotlin` directory.
57
-
3. Generated code overrides the code present `xap-sdk/src/main/kotlin` directory, affecting only the `operations` and `models` packages.
83
+
3. Generated code overrides the code present `xap-sdk/src/main/kotlin` directory, affecting only the `operations` and
84
+
`models` packages.
58
85
4. The generated code is then post-processed to apply additional customizations and optimizations.
59
86
5. Finally, the code is formatted and linted using Ktlint to ensure code quality and consistency.
87
+
88
+
## Build-Logic Module
89
+
90
+
The `buildSrc` module is
91
+
a [Gradle build logic module](https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html#sec:using_buildsrc)
92
+
that contains custom Gradle plugins and shared build logic used across the project. It allows for better organization
93
+
and reusability of build scripts and configurations.
94
+
95
+
The `buildSrc` module is used to define OpenAPI Generator customizations, such as custom mustache lambdas. This module
96
+
can be used to define custom Gradle tasks, plugins, and other build-related logic that can be reused across the project.
97
+
It is automatically included in the build process and can be used to extend the functionality of Gradle.
0 commit comments