Skip to content

Commit 42d647f

Browse files
committed
Define comma-separated string params as non-exploding arrays
1 parent 16e3d53 commit 42d647f

File tree

8 files changed

+173
-76
lines changed

8 files changed

+173
-76
lines changed

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/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: 31 additions & 17 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,27 @@ 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+
type: array
142+
items:
143+
type: string
144+
uniqueItems: true
141145
example: 11,12
142146
- name: carClasses
143147
in: query
144148
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.
149+
explode: false
145150
schema:
146-
type: string
151+
type: array
152+
items:
153+
type: string
154+
uniqueItems: true
147155
example: 'economy'
148156
- name: discount1.supplier
149157
in: query
@@ -168,21 +176,26 @@ paths:
168176
- name: transmissions
169177
in: query
170178
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.
179+
explode: false
171180
schema:
172-
type: string
181+
type: array
182+
items:
183+
type: string
184+
uniqueItems: true
173185
- name: airConditioning
174186
in: query
175187
description: Specify whether to filter for cars that include or exclude air conditioning.
176188
schema:
177-
type: string
178-
enum:
179-
- 'true'
180-
- 'false'
189+
type: boolean
181190
- name: carTypes
182191
in: query
183192
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.
193+
explode: false
184194
schema:
185-
type: string
195+
type: array
196+
items:
197+
type: string
198+
uniqueItems: true
186199
example: C,E
187200
- name: unit
188201
in: query
@@ -196,11 +209,12 @@ paths:
196209
in: query
197210
description: The age of the driver that will be renting the car.This value is required in the UK and optional elsewhere.
198211
schema:
199-
type: string
200-
example: '18'
212+
type: integer
213+
example: 18
201214
- name: links
202215
in: query
203216
description: 'WS = WebSearch, AD = ApiDetails, WD = WebDetails'
217+
explode: false
204218
schema:
205219
type: array
206220
items:
@@ -612,11 +626,11 @@ components:
612626
format: date-time
613627
example: '2021-03-09T07:08:00Z'
614628
OnlineCheckIn:
615-
type: boolean
629+
type: Boolean
616630
description: Indicate whether the supplier supports online checkin
617631
example: true
618632
SkipTheCounter:
619-
type: boolean
633+
type: Boolean
620634
description: Indicate whether the supplier supports skip the counter
621635
example: true
622636
VehicleDetails:
@@ -1399,11 +1413,11 @@ components:
13991413
type: object
14001414
properties:
14011415
OnlineCheckIn:
1402-
type: boolean
1416+
type: Boolean
14031417
description: Indicate whether the supplier supports online checkin
14041418
example: true
14051419
SkipTheCounter:
1406-
type: boolean
1420+
type: Boolean
14071421
description: Indicate whether the supplier supports skip the counter
14081422
example: true
14091423
VehicleDetails:

0 commit comments

Comments
 (0)