Skip to content

Commit acd4272

Browse files
committed
Rename MinimalOpenAPI to UnifiedOpenAPI
Signed-off-by: Matheus Cruz <[email protected]>
1 parent 6a0f9dd commit acd4272

File tree

6 files changed

+120
-121
lines changed

6 files changed

+120
-121
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private void param(
135135
collectorMap.put(parameter.getName(), origMap.remove(name));
136136
} else if (parameter.getRequired()) {
137137

138-
MinimalOpenAPI.Schema schema = parameter.getSchema();
138+
UnifiedOpenAPI.Schema schema = parameter.getSchema();
139139
Object defaultValue = schema != null ? schema._default() : null;
140140
if (defaultValue != null) {
141141
collectorMap.put(name, defaultValue);
@@ -145,10 +145,10 @@ private void param(
145145
}
146146
}
147147

148-
private MinimalOpenAPI readMinimalOpenAPI(ExternalResourceHandler handler) {
148+
private UnifiedOpenAPI readMinimalOpenAPI(ExternalResourceHandler handler) {
149149
ObjectMapper objectMapper = WorkflowFormat.fromFileName(handler.name()).mapper();
150150
try (InputStream is = handler.open()) {
151-
return objectMapper.readValue(is, MinimalOpenAPI.class);
151+
return objectMapper.readValue(is, UnifiedOpenAPI.class);
152152
} catch (IOException e) {
153153
throw new UncheckedIOException("Error while reading OpenAPI document " + handler.name(), e);
154154
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public OpenAPIProcessor(String operationId) {
2626
this.operationId = Objects.requireNonNull(operationId);
2727
}
2828

29-
OperationDefinition parse(MinimalOpenAPI minimalOpenAPI) {
29+
OperationDefinition parse(UnifiedOpenAPI unifiedOpenAPI) {
3030
Optional<OperationDefinition> operationDefinition =
31-
minimalOpenAPI.findOperationById(this.operationId);
31+
unifiedOpenAPI.findOperationById(this.operationId);
3232
return operationDefinition.orElseThrow(
3333
() ->
3434
new IllegalArgumentException("Operation with ID '" + this.operationId + "' not found"));

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
class OperationDefinition {
2424

25-
private final MinimalOpenAPI.Operation operation;
25+
private final UnifiedOpenAPI.Operation operation;
2626
private final String method;
27-
private final MinimalOpenAPI openAPI;
27+
private final UnifiedOpenAPI openAPI;
2828
private final String path;
2929

3030
OperationDefinition(
31-
MinimalOpenAPI openAPI, MinimalOpenAPI.Operation operation, String path, String method) {
31+
UnifiedOpenAPI openAPI, UnifiedOpenAPI.Operation operation, String path, String method) {
3232

3333
this.openAPI = Objects.requireNonNull(openAPI, "openAPI cannot be null");
3434
this.operation = Objects.requireNonNull(operation, "operation cannot be null");
@@ -44,7 +44,7 @@ String getPath() {
4444
return path;
4545
}
4646

47-
MinimalOpenAPI.Operation getOperation() {
47+
UnifiedOpenAPI.Operation getOperation() {
4848
return operation;
4949
}
5050

@@ -64,7 +64,7 @@ private List<ParameterDefinition> getOpenApiParameters() {
6464

6565
List<ParameterDefinition> paramDefinitions = new ArrayList<>();
6666
if (operation.hasParameters()) {
67-
for (MinimalOpenAPI.Parameter parameter : operation.parameters()) {
67+
for (UnifiedOpenAPI.Parameter parameter : operation.parameters()) {
6868
if (parameter.in().equals("body")) {
6969
continue; // body parameters are handled separately
7070
}
@@ -75,21 +75,21 @@ private List<ParameterDefinition> getOpenApiParameters() {
7575
}
7676
}
7777

78-
if (openAPI.swaggerVersion().equals(MinimalOpenAPI.SwaggerVersion.SWAGGER_V2)) {
78+
if (openAPI.swaggerVersion().equals(UnifiedOpenAPI.SwaggerVersion.SWAGGER_V2)) {
7979
operation.parameters().stream()
8080
.filter(p -> p.in().equals("body"))
8181
.forEach(
8282
p -> {
83-
MinimalOpenAPI.Schema schema = p.schema();
83+
UnifiedOpenAPI.Schema schema = p.schema();
8484
if (schema.hasRef()) {
8585
String ref = schema.ref();
8686
schema = openAPI.resolveSchema(ref);
8787
}
8888

8989
if (schema != null && schema.hasProperties()) {
90-
Map<String, MinimalOpenAPI.Schema> properties = schema.properties();
90+
Map<String, UnifiedOpenAPI.Schema> properties = schema.properties();
9191
for (String fieldName : properties.keySet()) {
92-
MinimalOpenAPI.Schema fieldSchema = properties.get(fieldName);
92+
UnifiedOpenAPI.Schema fieldSchema = properties.get(fieldName);
9393
boolean isRequired = schema.requiredFields().contains(fieldName);
9494
paramDefinitions.add(
9595
new ParameterDefinition(fieldName, "body", isRequired, fieldSchema));
@@ -109,18 +109,18 @@ private List<ParameterDefinition> getOpenApiParameters() {
109109
}
110110

111111
private List<ParameterDefinition> parametersFromRequestBody(
112-
MinimalOpenAPI.RequestBody requestBody) {
112+
UnifiedOpenAPI.RequestBody requestBody) {
113113
if (requestBody == null) {
114114
return List.of();
115115
}
116116

117-
MinimalOpenAPI.Content content = requestBody.content();
117+
UnifiedOpenAPI.Content content = requestBody.content();
118118
if (!content.isApplicationJson()) {
119119
return List.of();
120120
}
121121

122-
MinimalOpenAPI.MediaType mediaType = content.applicationJson();
123-
MinimalOpenAPI.Schema schema = mediaType.schema();
122+
UnifiedOpenAPI.MediaType mediaType = content.applicationJson();
123+
UnifiedOpenAPI.Schema schema = mediaType.schema();
124124

125125
// resolve $ref if present
126126
if (schema != null && schema.hasRef()) {
@@ -132,11 +132,11 @@ private List<ParameterDefinition> parametersFromRequestBody(
132132
return List.of();
133133
}
134134

135-
Map<String, MinimalOpenAPI.Schema> properties = schema.properties();
135+
Map<String, UnifiedOpenAPI.Schema> properties = schema.properties();
136136
List<ParameterDefinition> paramDefinitions = new ArrayList<>();
137137

138138
for (String fieldName : properties.keySet()) {
139-
MinimalOpenAPI.Schema fieldSchema = properties.get(fieldName);
139+
UnifiedOpenAPI.Schema fieldSchema = properties.get(fieldName);
140140
boolean isRequired = schema.requiredFields().contains(fieldName);
141141
paramDefinitions.add(new ParameterDefinition(fieldName, "body", isRequired, fieldSchema));
142142
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ParameterDefinition {
2222
private final String name;
2323
private final String in;
2424
private final boolean required;
25-
private final MinimalOpenAPI.Schema schema;
25+
private final UnifiedOpenAPI.Schema schema;
2626

2727
ParameterDefinition(JsonNode parameter) {
2828
this(
@@ -32,7 +32,7 @@ class ParameterDefinition {
3232
null);
3333
}
3434

35-
ParameterDefinition(String name, String in, boolean required, MinimalOpenAPI.Schema schema) {
35+
ParameterDefinition(String name, String in, boolean required, UnifiedOpenAPI.Schema schema) {
3636
this.name = name;
3737
this.in = in;
3838
this.required = required;
@@ -51,7 +51,7 @@ public boolean getRequired() {
5151
return required;
5252
}
5353

54-
public MinimalOpenAPI.Schema getSchema() {
54+
public UnifiedOpenAPI.Schema getSchema() {
5555
return schema;
5656
}
5757
}

impl/openapi/src/main/java/io/serverlessworkflow/impl/executors/openapi/MinimalOpenAPI.java renamed to impl/openapi/src/main/java/io/serverlessworkflow/impl/executors/openapi/UnifiedOpenAPI.java

Lines changed: 80 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.databind.JsonNode;
21-
2221
import java.util.List;
2322
import java.util.Locale;
2423
import java.util.Map;
@@ -27,7 +26,7 @@
2726
import java.util.Set;
2827

2928
@JsonIgnoreProperties(ignoreUnknown = true)
30-
public record MinimalOpenAPI(
29+
public record UnifiedOpenAPI(
3130
String swagger,
3231
List<Server> servers,
3332
String host,
@@ -138,97 +137,97 @@ private Schema resolveRefSwaggerV2(String ref) {
138137
@JsonIgnoreProperties(ignoreUnknown = true)
139138
public record Server(String url) {}
140139

141-
@JsonIgnoreProperties(ignoreUnknown = true)
142-
public static final class PathItem {
143-
private final Operation get;
144-
private final Operation post;
145-
private final Operation put;
146-
private final Operation delete;
147-
private final Operation patch;
148-
private final Operation head;
149-
private final Operation options;
150-
private final Set<HttpOperation> methods;
151-
152-
public PathItem(
153-
Operation get,
154-
Operation post,
155-
Operation put,
156-
Operation delete,
157-
Operation patch,
158-
Operation head,
159-
Operation options) {
160-
this.get = get;
161-
this.post = post;
162-
this.put = put;
163-
this.delete = delete;
164-
this.patch = patch;
165-
this.head = head;
166-
this.options = options;
167-
this.methods = buildMethods();
168-
}
140+
@JsonIgnoreProperties(ignoreUnknown = true)
141+
public static final class PathItem {
142+
private final Operation get;
143+
private final Operation post;
144+
private final Operation put;
145+
private final Operation delete;
146+
private final Operation patch;
147+
private final Operation head;
148+
private final Operation options;
149+
private final Set<HttpOperation> methods;
150+
151+
public PathItem(
152+
Operation get,
153+
Operation post,
154+
Operation put,
155+
Operation delete,
156+
Operation patch,
157+
Operation head,
158+
Operation options) {
159+
this.get = get;
160+
this.post = post;
161+
this.put = put;
162+
this.delete = delete;
163+
this.patch = patch;
164+
this.head = head;
165+
this.options = options;
166+
this.methods = buildMethods();
167+
}
169168

170-
private Set<HttpOperation> buildMethods() {
171-
return Set.of(
172-
new HttpOperation("get", get),
173-
new HttpOperation("post", post),
174-
new HttpOperation("put", put),
175-
new HttpOperation("delete", delete),
176-
new HttpOperation("patch", patch),
177-
new HttpOperation("head", head),
178-
new HttpOperation("options", options));
179-
}
169+
private Set<HttpOperation> buildMethods() {
170+
return Set.of(
171+
new HttpOperation("get", get),
172+
new HttpOperation("post", post),
173+
new HttpOperation("put", put),
174+
new HttpOperation("delete", delete),
175+
new HttpOperation("patch", patch),
176+
new HttpOperation("head", head),
177+
new HttpOperation("options", options));
178+
}
180179

181-
Set<HttpOperation> methods() {
182-
return Set.copyOf(methods);
183-
}
180+
Set<HttpOperation> methods() {
181+
return Set.copyOf(methods);
182+
}
184183

185-
public Operation get() {
186-
return get;
187-
}
184+
public Operation get() {
185+
return get;
186+
}
188187

189-
public Operation post() {
190-
return post;
191-
}
188+
public Operation post() {
189+
return post;
190+
}
192191

193-
public Operation put() {
194-
return put;
195-
}
192+
public Operation put() {
193+
return put;
194+
}
196195

197-
public Operation delete() {
198-
return delete;
199-
}
196+
public Operation delete() {
197+
return delete;
198+
}
200199

201-
public Operation patch() {
202-
return patch;
203-
}
200+
public Operation patch() {
201+
return patch;
202+
}
204203

205-
public Operation head() {
206-
return head;
207-
}
204+
public Operation head() {
205+
return head;
206+
}
208207

209-
public Operation options() {
210-
return options;
211-
}
208+
public Operation options() {
209+
return options;
210+
}
212211

213-
@Override
214-
public boolean equals(Object obj) {
215-
if (obj == this) return true;
216-
if (obj == null || obj.getClass() != this.getClass()) return false;
217-
var that = (PathItem) obj;
218-
return Objects.equals(this.get, that.get) &&
219-
Objects.equals(this.post, that.post) &&
220-
Objects.equals(this.put, that.put) &&
221-
Objects.equals(this.delete, that.delete) &&
222-
Objects.equals(this.patch, that.patch) &&
223-
Objects.equals(this.head, that.head) &&
224-
Objects.equals(this.options, that.options);
225-
}
212+
@Override
213+
public boolean equals(Object obj) {
214+
if (obj == this) return true;
215+
if (obj == null || obj.getClass() != this.getClass()) return false;
216+
var that = (PathItem) obj;
217+
return Objects.equals(this.get, that.get)
218+
&& Objects.equals(this.post, that.post)
219+
&& Objects.equals(this.put, that.put)
220+
&& Objects.equals(this.delete, that.delete)
221+
&& Objects.equals(this.patch, that.patch)
222+
&& Objects.equals(this.head, that.head)
223+
&& Objects.equals(this.options, that.options);
224+
}
226225

227-
@Override
228-
public int hashCode() {
229-
return Objects.hash(get, post, put, delete, patch, head, options);
230-
}
226+
@Override
227+
public int hashCode() {
228+
return Objects.hash(get, post, put, delete, patch, head, options);
231229
}
230+
}
232231

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

0 commit comments

Comments
 (0)