Skip to content

Commit 7e992f9

Browse files
committed
Distinguish Categories correctly
1 parent 456cfc1 commit 7e992f9

File tree

8 files changed

+896
-136
lines changed

8 files changed

+896
-136
lines changed

openapi/openapi.yml

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ components:
130130
categories:
131131
type: array
132132
items:
133-
$ref: '#/components/schemas/Category'
133+
$ref: '#/components/schemas/CategoryAll'
134134
rooms:
135135
type: array
136136
items:
@@ -141,28 +141,50 @@ components:
141141
- rooms
142142
- sessions
143143
- speakers
144-
Category:
144+
BaseCategory:
145145
type: object
146146
readOnly: true
147147
properties:
148148
id:
149149
type: integer
150-
title:
151-
type: string
152-
items:
153-
type: array
154-
items:
155-
$ref: '#/components/schemas/CategoryItem'
156150
sort:
157151
type: integer
158-
type:
159-
type: string
160152
required:
161153
- id
162-
- items
163154
- sort
164-
- title
165-
- type
155+
CategorySession:
156+
allOf:
157+
- $ref: '#/components/schemas/BaseCategory'
158+
- type: object
159+
readOnly: true
160+
properties:
161+
name:
162+
type: string
163+
categoryItems:
164+
type: array
165+
items:
166+
$ref: '#/components/schemas/CategoryItem'
167+
required:
168+
- name
169+
- categoryItems
170+
CategoryAll:
171+
allOf:
172+
- $ref: '#/components/schemas/BaseCategory'
173+
- type: object
174+
readOnly: true
175+
properties:
176+
title:
177+
type: string
178+
items:
179+
type: array
180+
items:
181+
$ref: '#/components/schemas/CategoryItemAll'
182+
type:
183+
type: string
184+
required:
185+
- title
186+
- items
187+
- type
166188
CategoryItem:
167189
type: object
168190
readOnly: true
@@ -171,12 +193,19 @@ components:
171193
type: integer
172194
name:
173195
type: string
174-
sort:
175-
type: integer
176196
required:
177197
- id
178198
- name
179-
- sort
199+
CategoryItemAll:
200+
allOf:
201+
- $ref: '#/components/schemas/CategoryItem'
202+
- type: object
203+
readOnly: true
204+
properties:
205+
sort:
206+
type: integer
207+
required:
208+
- sort
180209
Link:
181210
type: object
182211
readOnly: true
@@ -304,7 +333,7 @@ components:
304333
- startsAt
305334
- status
306335
- title
307-
Session: # only for Sessions Endpoint
336+
Session:
308337
allOf:
309338
- $ref: '#/components/schemas/BaseSession'
310339
- type: object
@@ -324,11 +353,16 @@ components:
324353
type: array
325354
items:
326355
$ref: '#/components/schemas/QuestionAnswerFull'
356+
categories:
357+
type: array
358+
items:
359+
$ref: '#/components/schemas/CategorySession'
327360
required:
328361
- id
329362
- room
330363
- questionAnswers
331364
- speakers
365+
- categories
332366
SessionAll:
333367
allOf:
334368
- $ref: '#/components/schemas/BaseSession'

sessionize-java-client/src/generated/java/software/xdev/sessionize/model/AllResult.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.ArrayList;
2424
import java.util.Arrays;
2525
import java.util.List;
26-
import software.xdev.sessionize.model.Category;
26+
import software.xdev.sessionize.model.CategoryAll;
2727
import software.xdev.sessionize.model.Question;
2828
import software.xdev.sessionize.model.Room;
2929
import software.xdev.sessionize.model.SessionAll;
@@ -56,7 +56,7 @@ public class AllResult {
5656
private List<Question> questions = new ArrayList<>();
5757

5858
public static final String JSON_PROPERTY_CATEGORIES = "categories";
59-
private List<Category> categories = new ArrayList<>();
59+
private List<CategoryAll> categories = new ArrayList<>();
6060

6161
public static final String JSON_PROPERTY_ROOMS = "rooms";
6262
private List<Room> rooms = new ArrayList<>();
@@ -166,13 +166,13 @@ public void setQuestions(List<Question> questions) {
166166
}
167167

168168

169-
public AllResult categories(List<Category> categories) {
169+
public AllResult categories(List<CategoryAll> categories) {
170170

171171
this.categories = categories;
172172
return this;
173173
}
174174

175-
public AllResult addCategoriesItem(Category categoriesItem) {
175+
public AllResult addCategoriesItem(CategoryAll categoriesItem) {
176176
if (this.categories == null) {
177177
this.categories = new ArrayList<>();
178178
}
@@ -188,14 +188,14 @@ public AllResult addCategoriesItem(Category categoriesItem) {
188188
@JsonProperty(JSON_PROPERTY_CATEGORIES)
189189
@JsonInclude(value = JsonInclude.Include.ALWAYS)
190190

191-
public List<Category> getCategories() {
191+
public List<CategoryAll> getCategories() {
192192
return categories;
193193
}
194194

195195

196196
@JsonProperty(JSON_PROPERTY_CATEGORIES)
197197
@JsonInclude(value = JsonInclude.Include.ALWAYS)
198-
public void setCategories(List<Category> categories) {
198+
public void setCategories(List<CategoryAll> categories) {
199199
this.categories = categories;
200200
}
201201

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
* Sessionize JSON-REST API
3+
* Sessionize JSON-REST API documentation by XDEV Software
4+
*
5+
* The version of the OpenAPI document: 2.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package software.xdev.sessionize.model;
15+
16+
import java.util.Objects;
17+
import java.util.Arrays;
18+
import com.fasterxml.jackson.annotation.JsonInclude;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.annotation.JsonCreator;
21+
import com.fasterxml.jackson.annotation.JsonTypeName;
22+
import com.fasterxml.jackson.annotation.JsonValue;
23+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
24+
import com.fasterxml.jackson.annotation.JsonTypeName;
25+
import java.io.UnsupportedEncodingException;
26+
import java.net.URLEncoder;
27+
import java.util.StringJoiner;
28+
29+
/**
30+
* BaseCategory
31+
*/
32+
@JsonPropertyOrder({
33+
BaseCategory.JSON_PROPERTY_ID,
34+
BaseCategory.JSON_PROPERTY_SORT
35+
})
36+
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
37+
public class BaseCategory {
38+
public static final String JSON_PROPERTY_ID = "id";
39+
private Integer id;
40+
41+
public static final String JSON_PROPERTY_SORT = "sort";
42+
private Integer sort;
43+
44+
public BaseCategory() {
45+
}
46+
47+
public BaseCategory id(Integer id) {
48+
49+
this.id = id;
50+
return this;
51+
}
52+
53+
/**
54+
* Get id
55+
* @return id
56+
**/
57+
@jakarta.annotation.Nonnull
58+
@JsonProperty(JSON_PROPERTY_ID)
59+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
60+
61+
public Integer getId() {
62+
return id;
63+
}
64+
65+
66+
@JsonProperty(JSON_PROPERTY_ID)
67+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
68+
public void setId(Integer id) {
69+
this.id = id;
70+
}
71+
72+
73+
public BaseCategory sort(Integer sort) {
74+
75+
this.sort = sort;
76+
return this;
77+
}
78+
79+
/**
80+
* Get sort
81+
* @return sort
82+
**/
83+
@jakarta.annotation.Nonnull
84+
@JsonProperty(JSON_PROPERTY_SORT)
85+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
86+
87+
public Integer getSort() {
88+
return sort;
89+
}
90+
91+
92+
@JsonProperty(JSON_PROPERTY_SORT)
93+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
94+
public void setSort(Integer sort) {
95+
this.sort = sort;
96+
}
97+
98+
@Override
99+
public boolean equals(Object o) {
100+
if (this == o) {
101+
return true;
102+
}
103+
if (o == null || getClass() != o.getClass()) {
104+
return false;
105+
}
106+
BaseCategory baseCategory = (BaseCategory) o;
107+
return Objects.equals(this.id, baseCategory.id) &&
108+
Objects.equals(this.sort, baseCategory.sort);
109+
}
110+
111+
@Override
112+
public int hashCode() {
113+
return Objects.hash(id, sort);
114+
}
115+
116+
@Override
117+
public String toString() {
118+
StringBuilder sb = new StringBuilder();
119+
sb.append("class BaseCategory {\n");
120+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
121+
sb.append(" sort: ").append(toIndentedString(sort)).append("\n");
122+
sb.append("}");
123+
return sb.toString();
124+
}
125+
126+
/**
127+
* Convert the given object to string with each line indented by 4 spaces
128+
* (except the first line).
129+
*/
130+
private String toIndentedString(Object o) {
131+
if (o == null) {
132+
return "null";
133+
}
134+
return o.toString().replace("\n", "\n ");
135+
}
136+
137+
/**
138+
* Convert the instance into URL query string.
139+
*
140+
* @return URL query string
141+
*/
142+
public String toUrlQueryString() {
143+
return toUrlQueryString(null);
144+
}
145+
146+
/**
147+
* Convert the instance into URL query string.
148+
*
149+
* @param prefix prefix of the query string
150+
* @return URL query string
151+
*/
152+
public String toUrlQueryString(String prefix) {
153+
String suffix = "";
154+
String containerSuffix = "";
155+
String containerPrefix = "";
156+
if (prefix == null) {
157+
// style=form, explode=true, e.g. /pet?name=cat&type=manx
158+
prefix = "";
159+
} else {
160+
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
161+
prefix = prefix + "[";
162+
suffix = "]";
163+
containerSuffix = "]";
164+
containerPrefix = "[";
165+
}
166+
167+
StringJoiner joiner = new StringJoiner("&");
168+
169+
// add `id` to the URL query string
170+
if (getId() != null) {
171+
try {
172+
joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20")));
173+
} catch (UnsupportedEncodingException e) {
174+
// Should never happen, UTF-8 is always supported
175+
throw new RuntimeException(e);
176+
}
177+
}
178+
179+
// add `sort` to the URL query string
180+
if (getSort() != null) {
181+
try {
182+
joiner.add(String.format("%ssort%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSort()), "UTF-8").replaceAll("\\+", "%20")));
183+
} catch (UnsupportedEncodingException e) {
184+
// Should never happen, UTF-8 is always supported
185+
throw new RuntimeException(e);
186+
}
187+
}
188+
189+
return joiner.toString();
190+
}
191+
192+
}
193+

0 commit comments

Comments
 (0)