Skip to content

Commit 7817490

Browse files
authored
feat: update transacation-id header and comma-separated string params (#16)
1 parent 9edb9eb commit 7817490

File tree

10 files changed

+211
-78
lines changed

10 files changed

+211
-78
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2022 Expedia, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.expediagroup.sdk.core.constant
17+
18+
internal object HeaderKey {
19+
const val PAGINATION_TOTAL_RESULTS = "pagination-total-results"
20+
21+
const val LINK = "link"
22+
23+
const val TRANSACTION_ID = "Partner-Transaction-Id"
24+
25+
const val X_SDK_TITLE = "x-sdk-title"
26+
}

customizations/generator/openapi/src/main/kotlin/com/expediagroup/sdk/generators/openapi/OpenApiSdkGenerator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class OpenApiSdkGenerator {
4242
"LinkableOperation.kt",
4343
"PropertyConstraintViolation.kt",
4444
"PropertyConstraintsValidator.kt",
45-
"PropertyConstraintViolationException.kt"
45+
"PropertyConstraintViolationException.kt",
46+
"ApiAbstractions.kt"
4647
)
4748

4849
companion object {

customizations/generator/openapi/src/main/resources/post-processor/assets/templates/get-lodging-listings-operation-params/rooms.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@ fun rooms(rooms: List<Room>) =
22
apply {
33
rooms.elementAtOrNull(0)?.let {
44
this.room1Adults = it.adults
5-
this.room1ChildAges = it.childAges?.joinToString(",")
5+
this.room1ChildAges = it.childAges?.map { item -> item.toString() }
66
}
77

88
rooms.elementAtOrNull(1)?.let {
99
this.room2Adults = it.adults
10-
this.room2ChildAges = it.childAges?.joinToString(",")
10+
this.room2ChildAges = it.childAges?.map { item -> item.toString() }
1111
}
1212

1313
rooms.elementAtOrNull(2)?.let {
1414
this.room3Adults = it.adults
15-
this.room3ChildAges = it.childAges?.joinToString(",")
15+
this.room3ChildAges = it.childAges?.map { item -> item.toString() }
1616
}
1717

1818
rooms.elementAtOrNull(3)?.let {
1919
this.room4Adults = it.adults
20-
this.room4ChildAges = it.childAges?.joinToString(",")
20+
this.room4ChildAges = it.childAges?.map { item -> item.toString() }
2121
}
2222

2323
rooms.elementAtOrNull(4)?.let {
2424
this.room5Adults = it.adults
25-
this.room5ChildAges = it.childAges?.joinToString(",")
25+
this.room5ChildAges = it.childAges?.map { item -> item.toString() }
2626
}
2727

2828
rooms.elementAtOrNull(5)?.let {
2929
this.room6Adults = it.adults
30-
this.room6ChildAges = it.childAges?.joinToString(",")
30+
this.room6ChildAges = it.childAges?.map { item -> item.toString() }
3131
}
3232

3333
rooms.elementAtOrNull(6)?.let {
3434
this.room7Adults = it.adults
35-
this.room7ChildAges = it.childAges?.joinToString(",")
35+
this.room7ChildAges = it.childAges?.map { item -> item.toString() }
3636
}
3737

3838
rooms.elementAtOrNull(7)?.let {
3939
this.room8Adults = it.adults
40-
this.room8ChildAges = it.childAges?.joinToString(",")
40+
this.room8ChildAges = it.childAges?.map { item -> item.toString() }
4141
}
4242
}

customizations/generator/openapi/src/main/resources/post-processor/assets/templates/get-lodging-quotes-operation-params/rooms.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@ fun rooms(rooms: List<Room>) =
22
apply {
33
rooms.elementAtOrNull(0)?.let {
44
this.room1Adults = it.adults
5-
this.room1ChildAges = it.childAges?.joinToString(",")
5+
this.room1ChildAges = it.childAges?.map { item -> item.toString() }
66
}
77

88
rooms.elementAtOrNull(1)?.let {
99
this.room2Adults = it.adults
10-
this.room2ChildAges = it.childAges?.joinToString(",")
10+
this.room2ChildAges = it.childAges?.map { item -> item.toString() }
1111
}
1212

1313
rooms.elementAtOrNull(2)?.let {
1414
this.room3Adults = it.adults
15-
this.room3ChildAges = it.childAges?.joinToString(",")
15+
this.room3ChildAges = it.childAges?.map { item -> item.toString() }
1616
}
1717

1818
rooms.elementAtOrNull(3)?.let {
1919
this.room4Adults = it.adults
20-
this.room4ChildAges = it.childAges?.joinToString(",")
20+
this.room4ChildAges = it.childAges?.map { item -> item.toString() }
2121
}
2222

2323
rooms.elementAtOrNull(4)?.let {
2424
this.room5Adults = it.adults
25-
this.room5ChildAges = it.childAges?.joinToString(",")
25+
this.room5ChildAges = it.childAges?.map { item -> item.toString() }
2626
}
2727

2828
rooms.elementAtOrNull(5)?.let {
2929
this.room6Adults = it.adults
30-
this.room6ChildAges = it.childAges?.joinToString(",")
30+
this.room6ChildAges = it.childAges?.map { item -> item.toString() }
3131
}
3232

3333
rooms.elementAtOrNull(6)?.let {
3434
this.room7Adults = it.adults
35-
this.room7ChildAges = it.childAges?.joinToString(",")
35+
this.room7ChildAges = it.childAges?.map { item -> item.toString() }
3636
}
3737

3838
rooms.elementAtOrNull(7)?.let {
3939
this.room8Adults = it.adults
40-
this.room8ChildAges = it.childAges?.joinToString(",")
40+
this.room8ChildAges = it.childAges?.map { item -> item.toString() }
4141
}
4242
}

customizations/generator/openapi/src/main/resources/templates/expediagroup-sdk/client.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class {{clientClassname}}Client private constructor(clientConfiguration: XapClie
4848
}
4949

5050
val extraHeaders = buildMap {
51-
put(HeaderKey.TRANSACTION_ID, operation.transactionId.dequeue().toString())
5251
put("key", configurationProvider.key ?: "")
5352
}
5453

@@ -145,4 +144,4 @@ class {{clientClassname}}Client private constructor(clientConfiguration: XapClie
145144
{{>client/paginatorMethods}}
146145
{{/isPaginatable}}
147146
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
148-
}
147+
}

customizations/generator/openapi/src/main/resources/templates/expediagroup-sdk/operation_params.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.expediagroup.sdk.{{namespace}}.operations
55

66
import com.expediagroup.sdk.core.model.OperationParams
7+
import {{packageName}}.infrastructure.*
78
import com.fasterxml.jackson.annotation.JsonProperty
89
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
910
import io.ktor.http.Headers
@@ -122,7 +123,7 @@
122123
{{#queryParams}}
123124
{{paramName}}?.let {
124125
{{#isContainer}}
125-
append("{{baseName}}", it{{#isEnum}}.map { it.value }{{/isEnum}}.joinToString(","))
126+
appendAll("{{baseName}}", toMultiValue(it{{#isEnum}}.map { item -> item.value }{{/isEnum}}, "{{collectionFormat}}"))
126127
{{/isContainer}}
127128
{{^isContainer}}
128129
append("{{baseName}}", it{{#isEnum}}.value{{/isEnum}}{{^isString}}.toString(){{/isString}})

examples/src/main/java/com/expediagroup/sdk/xap/examples/services/LodgingService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import com.expediagroup.sdk.xap.operations.GetLodgingQuotesOperationParams;
3030
import java.time.LocalDate;
3131
import java.util.ArrayList;
32+
import java.util.Arrays;
3233
import java.util.Collections;
34+
import java.util.HashSet;
3335
import java.util.UUID;
3436

3537
/**
@@ -47,7 +49,7 @@ public AvailabilityCalendarResponse getAvailabilityCalendars() {
4749
GetLodgingAvailabilityCalendarsOperationParams.builder()
4850
.partnerTransactionId(UUID.randomUUID().toString())
4951
//Comma-separated list of Expedia Property IDs.
50-
.propertyIds("87704892,36238803")
52+
.propertyIds(new HashSet<>(Arrays.asList("87704892", "36238803")))
5153
.build();
5254

5355
String key = System.getProperty("com.expediagroup.xapjavasdk.vrbokey");
@@ -153,7 +155,7 @@ public LodgingQuotesResponse getQuotes() {
153155
// Check-out 10 days from now
154156
.checkOut(LocalDate.now().plusDays(10))
155157
// Comma-separated list of Expedia Property IDs.
156-
.propertyIds("87704892,12410858")
158+
.propertyIds(new HashSet<>(Arrays.asList("87704892", "36238803")))
157159
// The links to return, WEB includes WS (Web Search Result Page) and
158160
// WD (Web Details Page)
159161
.links(Collections.singletonList(GetLodgingQuotesOperationParams.Links.WEB))

specs/xap-car.specs.yaml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ info:
1212
- EWS
1313
- XAP
1414
- Cars
15-
- CarSearchs
15+
- CarSearch
1616
- CarDetails
1717
tags:
1818
- name: Cars Listings
@@ -131,19 +131,29 @@ paths:
131131
in: query
132132
description: The maximum number of search results that will be returned by the query.
133133
schema:
134-
type: string
135-
example: '100'
134+
type: integer
135+
example: 100
136136
- name: suppliers
137137
in: query
138138
description: 'A list of supplier ids or supplier names to be used to filter search results.Multiple supplier names or ids may be separated by comma.Please see a full list of Expedia Vendor Codes & Names in the Related Links Section below.The max count of suppliers requested is limited to 20.Note: while you may filter using either supplier name or supplier ID, it is recommended that you use supplier ID, as this value will remain consistent in the event of a merger or other name change by the supplier.'
139+
explode: false
139140
schema:
140-
type: string
141-
example: 11,12
141+
type: array
142+
items:
143+
type: string
144+
uniqueItems: true
145+
example:
146+
- 11
147+
- 12
142148
- name: carClasses
143149
in: query
144150
description: A list of car classes to be used to filter search results.Multiple car classes may be separated by comma.Please see Class List in the Related Links Section below for all options.
151+
explode: false
145152
schema:
146-
type: string
153+
type: array
154+
items:
155+
type: string
156+
uniqueItems: true
147157
example: 'economy'
148158
- name: discount1.supplier
149159
in: query
@@ -168,21 +178,26 @@ paths:
168178
- name: transmissions
169179
in: query
170180
description: A list of car transmission drive codes to be used to filter search results.Multiple car classes may be separated by a comma.Please see a full list of Transmission Drive Codes in the Related Links Section below.
181+
explode: false
171182
schema:
172-
type: string
183+
type: array
184+
items:
185+
type: string
186+
uniqueItems: true
173187
- name: airConditioning
174188
in: query
175189
description: Specify whether to filter for cars that include or exclude air conditioning.
176190
schema:
177-
type: string
178-
enum:
179-
- 'true'
180-
- 'false'
191+
type: boolean
181192
- name: carTypes
182193
in: query
183194
description: A list of car types to be used to filter search results.Multiple car types may be separated by comma.Please see a full list of Car Type Codes in the Related Links Section below.
195+
explode: false
184196
schema:
185-
type: string
197+
type: array
198+
items:
199+
type: string
200+
uniqueItems: true
186201
example: C,E
187202
- name: unit
188203
in: query
@@ -196,11 +211,12 @@ paths:
196211
in: query
197212
description: The age of the driver that will be renting the car.This value is required in the UK and optional elsewhere.
198213
schema:
199-
type: string
200-
example: '18'
214+
type: integer
215+
example: 18
201216
- name: links
202217
in: query
203218
description: 'WS = WebSearch, AD = ApiDetails, WD = WebDetails'
219+
explode: false
204220
schema:
205221
type: array
206222
items:

0 commit comments

Comments
 (0)