Skip to content

Commit 60618ad

Browse files
committed
Removing empty classes
Some generated classes are empty and not really used Signed-off-by: Francisco Javier Tirado Sarti <ftirados@redhat.com>
1 parent 646d9ff commit 60618ad

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

api/src/main/resources/schema/workflow.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ $defs:
664664
basic:
665665
type: object
666666
oneOf:
667-
- properties:
667+
- title: BasicAuthenticationData
668+
properties:
668669
username:
669670
type: string
670671
description: The username to use.
@@ -680,7 +681,8 @@ $defs:
680681
bearer:
681682
type: object
682683
oneOf:
683-
- properties:
684+
- title: BearerAuthenticationData
685+
properties:
684686
token:
685687
type: string
686688
description: The bearer token to use.
@@ -693,7 +695,8 @@ $defs:
693695
oauth2:
694696
type: object
695697
oneOf:
696-
- properties:
698+
- title: OAuth2AutenthicationData
699+
properties:
697700
authority:
698701
type: string
699702
format: uri
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
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 io.serverlessworkflow.generator;
17+
18+
import com.fasterxml.jackson.databind.JsonNode;
19+
import com.sun.codemodel.JClassContainer;
20+
import com.sun.codemodel.JType;
21+
import org.jsonschema2pojo.Schema;
22+
import org.jsonschema2pojo.rules.RuleFactory;
23+
import org.jsonschema2pojo.rules.TypeRule;
24+
25+
public class EmptyObjectTypeRule extends TypeRule {
26+
27+
protected EmptyObjectTypeRule(RuleFactory ruleFactory) {
28+
super(ruleFactory);
29+
}
30+
31+
@Override
32+
public JType apply(
33+
String nodeName,
34+
JsonNode node,
35+
JsonNode parent,
36+
JClassContainer generatableType,
37+
Schema currentSchema) {
38+
return isEmptyObject(node)
39+
? generatableType.owner().ref(Object.class)
40+
: super.apply(nodeName, node, parent, generatableType, currentSchema);
41+
}
42+
43+
private boolean isEmptyObject(JsonNode node) {
44+
return node.size() == 1 && node.has("type") && node.get("type").asText().equals("object");
45+
}
46+
}

custom-generator/src/main/java/io/serverlessworkflow/generator/UnreferencedFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public Rule<JClassContainer, JType> getSchemaRule() {
2727
return new AllAnyOneOfSchemaRule(this);
2828
}
2929

30+
@Override
31+
public Rule<JClassContainer, JType> getTypeRule() {
32+
return new EmptyObjectTypeRule(this);
33+
}
34+
3035
@Override
3136
public Rule<JDefinedClass, JDefinedClass> getAdditionalPropertiesRule() {
3237
return new UnevaluatedPropertiesRule(this);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy