generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 23
feat: [OpenAPI] Make Spring Optional with Apache HttpClient #1046
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
888bc4d
Move resttemplate moustache into dedicated folder
rpanackal 3473fff
Revert "Move resttemplate moustache into dedicated folder"
rpanackal 7991ce9
Add apache-httpclient/api.moustache
rpanackal 6638e7a
openapi apache sample
rpanackal c08ceb6
remove ``@Generated`
rpanackal a697b6e
Add apache-client common generated classes and dependency
rpanackal 28e8135
dependency and formatting
rpanackal c3e438f
Add all required file (pruned later)
rpanackal c934b1f
Fix dependencies
rpanackal ea0eeb6
Simply api-apache-sample
rpanackal b81f4c2
Merge branch 'main' into feat/openapi/optional-spring-base
rpanackal 50a57bb
Fix version issue
rpanackal 6a33cf6
Pom config and exclusions
rpanackal cde369f
Set format skip false for sample module
rpanackal 50a0e0f
Merge branch 'main' into feat/openapi/optional-spring-base
rpanackal 1c0bef8
refactor: [OpenAPI] Part 1: Refactor Apache related files and templat…
rpanackal 84b4e9e
Merge branch 'main' into feat/openapi/optional-spring-base
rpanackal f02fd1d
Fix CI/CD
rpanackal cefb244
checkstyle
rpanackal 1632d2c
pmd
rpanackal 1e00604
pmd
rpanackal 4835a34
Update datamodel/openapi/openapi-generator/src/main/resources/openapi…
rpanackal de76c72
Review: Apache Method enum and ctor formatting
rpanackal 067ddc8
Merge remote-tracking branch 'origin/feat/openapi/optional-spring-bas…
rpanackal de01665
Update datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk…
rpanackal b7d623e
Fix compliance issue and formatting
rpanackal 1226e6f
Make return statement always present
rpanackal d8a945e
minor changes in mustache files
rpanackal 859a8f1
feat: [OpenAPI] Part 2: Testing Apache Client Support and some fixes.…
rpanackal f05242f
Fix missed line on merge
rpanackal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>com.sap.cloud.sdk.datamodel</groupId> | ||
| <artifactId>openapi-parent</artifactId> | ||
| <version>5.26.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>openapi-api-apache-sample</artifactId> | ||
|
|
||
| <properties> | ||
| <maven.compiler.source>22</maven.compiler.source> | ||
| <maven.compiler.target>22</maven.compiler.target> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.sap.cloud.sdk.datamodel</groupId> | ||
| <artifactId>openapi-core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>com.sap.cloud.sdk.datamodel</groupId> | ||
| <artifactId>openapi-generator-maven-plugin</artifactId> | ||
| <configuration> | ||
| <outputDirectory>${project.basedir}/src/main/java</outputDirectory> | ||
| <enableOneOfAnyOfGeneration>true</enableOneOfAnyOfGeneration> | ||
| <deleteOutputDirectory>true</deleteOutputDirectory> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <id>sample-generation</id> | ||
| <goals> | ||
| <goal>generate</goal> | ||
| </goals> | ||
| <phase>generate-sources</phase> | ||
| <configuration> | ||
| <inputSpec>${project.basedir}/src/main/resources/sodastore.yaml</inputSpec> | ||
| <apiPackage>com.sap.cloud.sdk.datamodel.openapi.apache.sample.api</apiPackage> | ||
| <modelPackage>com.sap.cloud.sdk.datamodel.openapi.apache.sample.model</modelPackage> | ||
| <additionalProperties> | ||
| <supportingFiles>true</supportingFiles> | ||
| <invokerPackage>com.sap.cloud.sdk.services.openapi.apache</invokerPackage> | ||
| <library>apache-httpclient</library> | ||
| <supportUrlQuery>false</supportUrlQuery> | ||
| <useOneOfInterfaces>true</useOneOfInterfaces> | ||
| <enumUnknownDefaultCase>true</enumUnknownDefaultCase> | ||
| <removeOperationIdPrefix>true</removeOperationIdPrefix> | ||
| <removeOperationIdPrefixDelimiter>\.</removeOperationIdPrefixDelimiter> | ||
| <removeOperationIdPrefixCount>3</removeOperationIdPrefixCount> | ||
| <!-- Custom Cloud SDK settings --> | ||
| <pojoConstructorVisibility>protected</pojoConstructorVisibility> | ||
| <useOneOfCreators>true</useOneOfCreators> | ||
| </additionalProperties> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>net.revelc.code.formatter</groupId> | ||
| <artifactId>formatter-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>format</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <skip>false</skip> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>net.revelc.code</groupId> | ||
| <artifactId>impsort-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>sort</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| <configuration> | ||
| <skip>false</skip> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
162 changes: 162 additions & 0 deletions
162
...sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/OrdersApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| /* | ||
| * SodaStore API | ||
| * API for managing soda products and orders in SodaStore. | ||
| * | ||
| * | ||
| * | ||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
| * https://openapi-generator.tech | ||
| * Do not edit the class manually. | ||
| */ | ||
|
|
||
| package com.sap.cloud.sdk.datamodel.openapi.apache.sample.api; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.StringJoiner; | ||
|
|
||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
| import com.sap.cloud.sdk.datamodel.openapi.apache.sample.model.Order; | ||
| import com.sap.cloud.sdk.services.openapi.apache.ApiClient; | ||
| import com.sap.cloud.sdk.services.openapi.apache.ApiException; | ||
| import com.sap.cloud.sdk.services.openapi.apache.BaseApi; | ||
| import com.sap.cloud.sdk.services.openapi.apache.Configuration; | ||
| import com.sap.cloud.sdk.services.openapi.apache.Pair; | ||
|
|
||
| public class OrdersApi extends BaseApi | ||
| { | ||
|
|
||
| public OrdersApi() | ||
| { | ||
| super(Configuration.getDefaultApiClient()); | ||
| } | ||
|
|
||
| public OrdersApi( ApiClient apiClient ) | ||
| { | ||
| super(apiClient); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new order | ||
| * | ||
| * @param order | ||
| * The order details (required) | ||
| * @return Order | ||
| * @throws ApiException | ||
| * if fails to make API call | ||
| */ | ||
| public Order ordersPost( @javax.annotation.Nonnull Order order ) | ||
| throws ApiException | ||
| { | ||
| return this.ordersPost(order, Collections.emptyMap()); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new order | ||
| * | ||
| * @param order | ||
| * The order details (required) | ||
| * @param additionalHeaders | ||
| * additionalHeaders for this call | ||
| * @return Order | ||
| * @throws ApiException | ||
| * if fails to make API call | ||
| */ | ||
| public Order ordersPost( @javax.annotation.Nonnull Order order, Map<String, String> additionalHeaders ) | ||
| throws ApiException | ||
| { | ||
| Object localVarPostBody = order; | ||
|
|
||
| // verify the required parameter 'order' is set | ||
| if( order == null ) { | ||
| throw new ApiException(400, "Missing the required parameter 'order' when calling ordersPost"); | ||
| } | ||
|
|
||
| // create path and map variables | ||
| String localVarPath = "/orders"; | ||
|
|
||
| StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); | ||
| String localVarQueryParameterBaseName; | ||
| List<Pair> localVarQueryParams = new ArrayList<Pair>(); | ||
| List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); | ||
| Map<String, String> localVarHeaderParams = new HashMap<String, String>(); | ||
| Map<String, String> localVarCookieParams = new HashMap<String, String>(); | ||
| Map<String, Object> localVarFormParams = new HashMap<String, Object>(); | ||
|
|
||
| localVarHeaderParams.putAll(additionalHeaders); | ||
|
|
||
| final String[] localVarAccepts = { "application/json" }; | ||
| final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); | ||
|
|
||
| final String[] localVarContentTypes = { "application/json" }; | ||
| final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); | ||
|
|
||
| String[] localVarAuthNames = new String[] { "apiKeyAuth" }; | ||
|
|
||
| TypeReference<Order> localVarReturnType = new TypeReference<Order>() | ||
| { | ||
| }; | ||
| return apiClient | ||
| .invokeAPI( | ||
| localVarPath, | ||
| "POST", | ||
| localVarQueryParams, | ||
| localVarCollectionQueryParams, | ||
| localVarQueryStringJoiner.toString(), | ||
| localVarPostBody, | ||
| localVarHeaderParams, | ||
| localVarCookieParams, | ||
| localVarFormParams, | ||
| localVarAccept, | ||
| localVarContentType, | ||
| localVarAuthNames, | ||
| localVarReturnType); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> T invokeAPI( | ||
rpanackal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String url, | ||
| String method, | ||
| Object request, | ||
| TypeReference<T> returnType, | ||
| Map<String, String> additionalHeaders ) | ||
| throws ApiException | ||
| { | ||
| String localVarPath = url.replace(apiClient.getBaseURL(), ""); | ||
| StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); | ||
| List<Pair> localVarQueryParams = new ArrayList<Pair>(); | ||
| List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); | ||
| Map<String, String> localVarHeaderParams = new HashMap<String, String>(); | ||
| Map<String, String> localVarCookieParams = new HashMap<String, String>(); | ||
| Map<String, Object> localVarFormParams = new HashMap<String, Object>(); | ||
|
|
||
| localVarHeaderParams.putAll(additionalHeaders); | ||
|
|
||
| final String[] localVarAccepts = { "application/json" }; | ||
| final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); | ||
|
|
||
| final String[] localVarContentTypes = { "application/json" }; | ||
| final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); | ||
|
|
||
| String[] localVarAuthNames = new String[] { "apiKeyAuth" }; | ||
|
|
||
| return apiClient | ||
| .invokeAPI( | ||
| localVarPath, | ||
| method, | ||
| localVarQueryParams, | ||
| localVarCollectionQueryParams, | ||
| localVarQueryStringJoiner.toString(), | ||
| request, | ||
| localVarHeaderParams, | ||
| localVarCookieParams, | ||
| localVarFormParams, | ||
| localVarAccept, | ||
| localVarContentType, | ||
| localVarAuthNames, | ||
| returnType); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Question/Optional)
It may be worth our time to check for alternatives to
javax.annotation.Nonnullnull-indicator annotations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely Jspecify is an option. But I guess that would merit a larger refactoring throughout the sdk