generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 20
feat: (OpenAPI) Fix class name generation for inline-object of //component/response
schemas
#835
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ca5a586
Initial
newtork 65277d5
Add test case
newtork 2f2b20e
Add test assertion
newtork 29b7a93
Fix PMD
newtork 919b0a6
Fix test assertion
newtork a59bf9b
Merge branch 'main' into fix-inline-object-component-response-schema
Jonas-Isr 7b85943
Merge remote-tracking branch 'origin/main' into fix-inline-object-com…
newtork 2aa215d
Change default file suffix from "Content" to ""
newtork 3d8c5b7
Update tests
newtork 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
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
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
81 changes: 81 additions & 0 deletions
81
...urces/DataModelGeneratorIntegrationTest/inlineobject-schemas-enabled/input/sodastore.yaml
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,81 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Soda Store API | ||
version: 1.0.0 | ||
description: API for managing sodas in a soda store | ||
|
||
paths: | ||
/sodas/{sodaId}: | ||
get: | ||
summary: Get details of a specific soda | ||
operationId: getSodaById | ||
parameters: | ||
- name: sodaId | ||
in: path | ||
description: ID of the soda to retrieve | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
'200': | ||
description: The requested soda | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Soda' | ||
'404': | ||
$ref: '#/components/responses/NotFound' | ||
'503': | ||
$ref: '#/components/responses/ServiceUnavailable' | ||
|
||
components: | ||
schemas: | ||
Soda: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
brand: | ||
type: string | ||
flavor: | ||
type: string | ||
price: | ||
type: number | ||
format: float | ||
required: | ||
- name | ||
- brand | ||
- flavor | ||
- price | ||
responses: | ||
NotFound: | ||
description: The specified resource was not found | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: Resource not found | ||
ServiceUnavailable: | ||
description: The service is currently unavailable | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: Resource not found | ||
application/xml: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: Resource not found |
106 changes: 106 additions & 0 deletions
106
...object-schemas-enabled/output/com/sap/cloud/sdk/services/inlineobject/api/DefaultApi.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,106 @@ | ||
/* | ||
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. | ||
*/ | ||
|
||
package com.sap.cloud.sdk.services.inlineobject.api; | ||
|
||
import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; | ||
import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; | ||
import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; | ||
import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; | ||
|
||
import com.sap.cloud.sdk.services.inlineobject.model.NotFound; | ||
import com.sap.cloud.sdk.services.inlineobject.model.ServiceUnavailableApplicationJson; | ||
import com.sap.cloud.sdk.services.inlineobject.model.ServiceUnavailableApplicationXml; | ||
import com.sap.cloud.sdk.services.inlineobject.model.Soda; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import com.google.common.annotations.Beta; | ||
|
||
import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; | ||
|
||
/** | ||
* Soda Store API in version 1.0.0. | ||
* | ||
* API for managing sodas in a soda store | ||
*/ | ||
public class DefaultApi extends AbstractOpenApiService { | ||
/** | ||
* Instantiates this API class to invoke operations on the Soda Store API. | ||
* | ||
* @param httpDestination The destination that API should be used with | ||
*/ | ||
public DefaultApi( @Nonnull final Destination httpDestination ) | ||
{ | ||
super(httpDestination); | ||
} | ||
|
||
/** | ||
* Instantiates this API class to invoke operations on the Soda Store API based on a given {@link ApiClient}. | ||
* | ||
* @param apiClient | ||
* ApiClient to invoke the API on | ||
*/ | ||
@Beta | ||
public DefaultApi( @Nonnull final ApiClient apiClient ) | ||
{ | ||
super(apiClient); | ||
} | ||
|
||
/** | ||
* <p>Get details of a specific soda</p> | ||
* <p></p> | ||
* <p><b>200</b> - The requested soda | ||
* <p><b>404</b> - The specified resource was not found | ||
* <p><b>503</b> - The service is currently unavailable | ||
* @param sodaId | ||
* ID of the soda to retrieve | ||
* @return Soda | ||
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API | ||
*/ | ||
@Nonnull | ||
public Soda getSodaById( @Nonnull final Long sodaId) throws OpenApiRequestException { | ||
final Object localVarPostBody = null; | ||
|
||
// verify the required parameter 'sodaId' is set | ||
if (sodaId == null) { | ||
throw new OpenApiRequestException("Missing the required parameter 'sodaId' when calling getSodaById"); | ||
} | ||
|
||
// create path and map variables | ||
final Map<String, Object> localVarPathParams = new HashMap<String, Object>(); | ||
localVarPathParams.put("sodaId", sodaId); | ||
final String localVarPath = UriComponentsBuilder.fromPath("/sodas/{sodaId}").buildAndExpand(localVarPathParams).toUriString(); | ||
|
||
final MultiValueMap<String, String> localVarQueryParams = new LinkedMultiValueMap<String, String>(); | ||
final HttpHeaders localVarHeaderParams = new HttpHeaders(); | ||
final MultiValueMap<String, Object> localVarFormParams = new LinkedMultiValueMap<String, Object>(); | ||
|
||
final String[] localVarAccepts = { | ||
"application/json", "application/xml" | ||
}; | ||
final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); | ||
final String[] localVarContentTypes = { }; | ||
final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); | ||
|
||
final String[] localVarAuthNames = new String[] { }; | ||
|
||
final ParameterizedTypeReference<Soda> localVarReturnType = new ParameterizedTypeReference<Soda>() {}; | ||
return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.