Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing code and applying experiment #2

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

elkezza
Copy link
Contributor

@elkezza elkezza commented Mar 7, 2024

Following the code review feedback, this pull request separates the core logic changes and auto-generated content into two distinct commits. The first commit includes the auto-generated SDK code using the OpenAPI Generator, while the second commit contains fixes and experiment, please review the changes and let me know if further adjustments are needed.

Thank you and Best regards, Saleh

- Initiated Java code generation using OpenAPI Generator with custom configurations to scaffold Exoscale4j SDK. Encountered and resolved multiple issues for seamless integration.
- Addressed an issue with 'AnyOf' constructs not being generated. Implemented 'AbstractOpenApiSchema' as a workaround to facilitate the required polymorphism in the data models.
- Corrected improper initialization of JsonSchemaPglookout and JsonSchemaKafka to match Java object instantiation syntax.
- Integrated Lombok library for improved readability and maintainability of the code by utilizing annotations for getters, setters, and constructors.
- Included Gson dependency for JSON processing capabilities, ensuring compatibility and extending serialization options.
- Added custom classes from Exoscale Custom Client for practical testing of Anti-Affinity Group creation functionality and to verify the robustness of the ApiClient.

### Configuration & Dependencies:
- The SDK is configured for Java 8 compatibility with Jackson serialization.
- Maven is employed as the build tool with the inclusion of a generated POM file.
- Gson library version 2.8.8 added to support JSON operations.

### SDK Code Generation

- Generated the SDK using OpenAPI Generator with the following command:
'''
openapi-generator generate -i https://openapi-v2.exoscale.com/source.json -g java -o /Users/saleh/Apps/tests/OpenAPIGeneratorV112 --api-package com.exoscale.api --model-package com.exoscale.model --invoker-package com.exoscale.invoker --group-id com.exoscale --artifact-id exoscale4j --artifact-version 1.0.0 --library webclient -p serializationLibrary=jackson -p dateLibrary=java8 -p useRuntimeException=true -p useOptional=true --global-property models,apis,supportingFiles --additional-properties=sourceFolder=src/main/java,generatePom=true,buildTool=maven
'''

- Breakdown of what each setting does:

- `-i`: Specifies the input OpenAPI spec file location.
- `-g java`: Sets the generator to use for code generation, which is Java in this case.
- `-o`: The output directory where the generated code will be saved.
- `--api-package`: The package name for API classes.
- `--model-package`: The package name for model classes.
- `--invoker-package`: The package name for the invoker or main client classes.
- `--group-id`, `--artifact-id`, `--artifact-version`: These options set Maven POM properties like group ID, artifact ID, and version.
- `--library webclient`: Specifies the library to use for HTTP calls (WebClient for asynchronous calls).
- `-p`: This parameter is used to pass additional properties for the generator. For example, `serializationLibrary=jackson` sets Jackson as the serialization library, and `dateLibrary=java8` uses Java 8 date and time API.
- `--global-property`: Used to specify which parts of the code (models, APIs, supporting files) should be generated.
- `--additional-properties`: Sets further properties like the source folder, whether to generate a POM file, and the build tool to use (Maven).
@elkezza elkezza merged commit 387499f into main Apr 19, 2024
1 check failed
@elkezza elkezza deleted the fixing-code-and-applying-experiment branch April 19, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant