18
18
import org .eclipse .esmf .ResolverConfigurationMixin ;
19
19
import org .eclipse .esmf .aspect .AspectToCommand ;
20
20
import org .eclipse .esmf .aspectmodel .generator .json .AspectModelJsonPayloadGenerator ;
21
+ import org .eclipse .esmf .aspectmodel .generator .json .JsonPayloadGenerationConfig ;
22
+ import org .eclipse .esmf .aspectmodel .generator .json .JsonPayloadGenerationConfigBuilder ;
21
23
22
24
import picocli .CommandLine ;
23
25
@@ -35,6 +37,12 @@ public class AspectToJsonCommand extends AbstractCommand {
35
37
description = "Output file path" )
36
38
private String outputFilePath = "-" ;
37
39
40
+ @ SuppressWarnings ( "FieldCanBeLocal" )
41
+ @ CommandLine .Option (
42
+ names = { "--add-type-attribute" , "-ta" },
43
+ description = "Add @type attribute for inherited Entities" )
44
+ private boolean addTypeAttribute = false ;
45
+
38
46
@ SuppressWarnings ( "FieldCanBeLocal" )
39
47
@ CommandLine .Option (
40
48
names = { "--details" },
@@ -55,8 +63,11 @@ public void run() {
55
63
setDetails ( details );
56
64
setResolverConfig ( resolverConfiguration );
57
65
66
+ final JsonPayloadGenerationConfig config = JsonPayloadGenerationConfigBuilder .builder ()
67
+ .addTypeAttributeForEntityInheritance ( addTypeAttribute )
68
+ .build ();
58
69
final AspectModelJsonPayloadGenerator generator = new AspectModelJsonPayloadGenerator (
59
- getInputHandler ( parentCommand .parentCommand .getInput () ).loadAspect () );
70
+ getInputHandler ( parentCommand .parentCommand .getInput () ).loadAspect (), config );
60
71
// we intentionally override the name of the generated artifact here to the name explicitly desired by the user (outputFilePath),
61
72
// as opposed to what the model thinks it should be called (name)
62
73
generator .generate ( name -> getStreamForFile ( outputFilePath ) );
0 commit comments