Skip to content

Commit 58d3dfd

Browse files
committed
Make PathItem a record
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
1 parent a4eaa95 commit 58d3dfd

File tree

1 file changed

+14
-91
lines changed

1 file changed

+14
-91
lines changed

impl/openapi/src/main/java/io/serverlessworkflow/impl/executors/openapi/UnifiedOpenAPI.java

Lines changed: 14 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -137,99 +137,22 @@ private Schema resolveRefSwaggerV2(String ref) {
137137
@JsonIgnoreProperties(ignoreUnknown = true)
138138
public record Server(String url) {}
139139

140-
@JsonIgnoreProperties(ignoreUnknown = true)
141-
public static final class PathItem {
142-
private Operation get;
143-
private Operation post;
144-
private Operation put;
145-
private Operation delete;
146-
private Operation patch;
147-
private Operation head;
148-
private Operation options;
149-
private Set<HttpOperation> methods;
150-
151-
PathItem() {}
152-
153-
public PathItem(
154-
Operation get,
155-
Operation post,
156-
Operation put,
157-
Operation delete,
158-
Operation patch,
159-
Operation head,
160-
Operation options) {
161-
this.get = get;
162-
this.post = post;
163-
this.put = put;
164-
this.delete = delete;
165-
this.patch = patch;
166-
this.head = head;
167-
this.options = options;
168-
this.methods = buildMethods();
169-
}
170-
171-
private Set<HttpOperation> buildMethods() {
172-
return Set.of(
173-
new HttpOperation("get", get),
174-
new HttpOperation("post", post),
175-
new HttpOperation("put", put),
176-
new HttpOperation("delete", delete),
177-
new HttpOperation("patch", patch),
178-
new HttpOperation("head", head),
179-
new HttpOperation("options", options));
180-
}
181-
182-
Set<HttpOperation> methods() {
183-
return Set.copyOf(methods);
184-
}
185-
186-
public Operation get() {
187-
return get;
188-
}
189-
190-
public Operation post() {
191-
return post;
192-
}
193-
194-
public Operation put() {
195-
return put;
196-
}
197-
198-
public Operation delete() {
199-
return delete;
200-
}
201-
202-
public Operation patch() {
203-
return patch;
204-
}
205-
206-
public Operation head() {
207-
return head;
208-
}
209-
210-
public Operation options() {
211-
return options;
212-
}
213-
214-
@Override
215-
public boolean equals(Object obj) {
216-
if (obj == this) return true;
217-
if (obj == null || obj.getClass() != this.getClass()) return false;
218-
var that = (PathItem) obj;
219-
return Objects.equals(this.get, that.get)
220-
&& Objects.equals(this.post, that.post)
221-
&& Objects.equals(this.put, that.put)
222-
&& Objects.equals(this.delete, that.delete)
223-
&& Objects.equals(this.patch, that.patch)
224-
&& Objects.equals(this.head, that.head)
225-
&& Objects.equals(this.options, that.options);
226-
}
140+
@JsonIgnoreProperties(ignoreUnknown = true)
141+
public record PathItem(Operation get, Operation post, Operation put, Operation delete, Operation patch,
142+
Operation head, Operation options) {
143+
144+
Set<HttpOperation> methods() {
145+
return Set.of(
146+
new HttpOperation("get", get),
147+
new HttpOperation("post", post),
148+
new HttpOperation("put", put),
149+
new HttpOperation("delete", delete),
150+
new HttpOperation("patch", patch),
151+
new HttpOperation("head", head),
152+
new HttpOperation("options", options));
153+
}
227154

228-
@Override
229-
public int hashCode() {
230-
return Objects.hash(get, post, put, delete, patch, head, options);
231155
}
232-
}
233156

234157
@JsonIgnoreProperties(ignoreUnknown = true)
235158
record HttpOperation(String method, Operation operation) {}

0 commit comments

Comments
 (0)