Skip to content

Commit dc2afc4

Browse files
committed
Merge branch 'main' into 2.10.x
2 parents a4c88a2 + e8c9704 commit dc2afc4

File tree

13 files changed

+198
-43
lines changed

13 files changed

+198
-43
lines changed

.github/workflows/dependency-update.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
18+
1819
- name: Submit Dependency Snapshot
1920
uses: advanced-security/maven-dependency-submission-action@v3

.github/workflows/pull-request-check.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,24 @@ jobs:
6969
java --version
7070
export MAVEN_OPTS="-Xmx4096m"
7171
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
72+
# Actual build of core SDK
7273
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
74+
# Build samm-cli executable jar and run integration tests
75+
unset JAVA_TOOL_OPTIONS
76+
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
7377
shell: bash
7478

7579
- name: Build native image
7680
if: matrix.os != 'macos-13'
7781
run: |
7882
export MAVEN_OPTS="-Xmx4096m"
79-
mvn -B -pl tools/samm-cli clean verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
83+
# Build native binary and run integration tests
84+
mvn -B -pl tools/samm-cli verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
8085
shell: bash
8186

8287
- name: Build native image (Mac)
8388
if: matrix.os == 'macos-13'
8489
run: |
85-
export MAVEN_OPTS="-Xmx4096m"
86-
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
8790
bundle="samm-bundle-DEV-SNAPSHOT-$(date +%s)"
8891
mkdir ${bundle}
8992
curl -Lo jre.tar.gz https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.6%2B7/OpenJDK21U-jre_x64_mac_hotspot_21.0.6_7.tar.gz

.github/workflows/release-workflow.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ jobs:
104104
105105
# Actual build of core SDK
106106
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean deploy -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -DaltDeploymentRepository=local::default::file://nexus-staging -Psign
107-
# Build of CLI
107+
# Build samm-cli executable jar and run integration tests
108108
unset JAVA_TOOL_OPTIONS
109-
mvn -B -pl tools/samm-cli clean verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
109+
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
110+
# Build native binary and run integration tests
111+
mvn -B -pl tools/samm-cli verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
110112
111113
# Create .tar.gz of samm-cli
112114
pushd tools/samm-cli/target
@@ -178,7 +180,7 @@ jobs:
178180
mvn versions:commit
179181
# Actual build of core SDK
180182
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
181-
# Build of CLI
183+
# Build samm-cli executable jar and run integration tests
182184
unset JAVA_TOOL_OPTIONS
183185
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
184186
shell: bash
@@ -266,9 +268,11 @@ jobs:
266268
267269
# Actual build of core SDK
268270
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
269-
# Build of CLI
271+
# Build samm-cli executable jar and run integration tests
270272
unset JAVA_TOOL_OPTIONS
271-
mvn -B -pl tools/samm-cli clean verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
273+
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
274+
# Build native binary and run integration tests
275+
mvn -B -pl tools/samm-cli verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
272276
shell: bash
273277

274278
- name: Upload Windows binary

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ Building the SDK requires a Java 21-compatible [GraalVM JDK](https://www.graalvm
5858

5959
To build the SDK core components, run the following command:
6060
```bash
61-
mvn -pl '!org.eclipse.esmf:samm-cli' clean install
61+
mvn -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative
6262
```
6363

6464
To also build SDK core components and the CLI tool, run the above command, followed by:
6565
```bash
66-
cd tools/samm-cli
67-
mvn -B clean verify
68-
mvn -B verify -Pnative
66+
mvn -pl org.eclipse.esmf:samm-cli clean verify
67+
mvn -pl org.eclipse.esmf:samm-cli verify -Pnative
6968
```
7069

7170
We are always looking forward to your contributions. For more details on how to contribute just take

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/AspectModelLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ private void setNamespaces( final Collection<AspectModelFile> files, final Colle
525525
final ModelElementFactory modelElementFactory = new ModelElementFactory( model, Map.of(), r -> null );
526526
final Resource namespaceResource = model.listStatements( null, RDF.type, SammNs.SAMM.Namespace() )
527527
.mapWith( Statement::getSubject )
528-
.toList().iterator().next();
528+
.toList().getFirst();
529529
namespaceDefinition = modelElementFactory.createBaseAttributes( namespaceResource );
530530
fileContainingNamespaceDefinition = elementFile;
531531
break;

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/versionupdate/BammUriRewriter.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,17 @@ public Model migrate( final Model sourceModel ) {
125125
}
126126

127127
public enum BammVersion {
128-
BAMM_1_0_0,
129-
BAMM_2_0_0;
128+
BAMM_1_0_0( "1.0.0" ),
129+
BAMM_2_0_0( "2.0.0" );
130+
131+
private final String versionString;
132+
133+
BammVersion( final String versionString ) {
134+
this.versionString = versionString;
135+
}
130136

131137
public String versionString() {
132-
return toString().replaceFirst( "BAMM_(\\d+)_(\\d+)_(\\d+)", "$1.$2.$3" );
138+
return versionString;
133139
}
134140
}
135141
}

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/versionupdate/SammMetaModelVersionUriRewriter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.eclipse.esmf.samm.KnownVersion;
2020

2121
public class SammMetaModelVersionUriRewriter extends AbstractUriRewriter {
22-
2322
public SammMetaModelVersionUriRewriter( final KnownVersion sourceVersion, final KnownVersion targetVersion ) {
2423
super( sourceVersion, targetVersion );
2524
}
@@ -31,15 +30,15 @@ public int order() {
3130

3231
@Override
3332
protected Optional<String> rewriteUri( final String oldUri, final Map<String, String> oldToNewNamespaces ) {
34-
final String[] uriParts = oldUri.split( "#" );
35-
if ( uriParts.length == 1 ) {
33+
final int indexOfHash = oldUri.indexOf( '#' );
34+
if ( indexOfHash == -1 ) {
35+
return Optional.empty();
36+
}
37+
final String newNamespace = oldToNewNamespaces.get( oldUri.substring( 0, indexOfHash + 1 ) );
38+
if ( newNamespace == null ) {
3639
return Optional.empty();
3740
}
38-
return oldToNewNamespaces.keySet()
39-
.stream()
40-
.filter( key -> key.equals( uriParts[0] + "#" ) )
41-
.findAny()
42-
.map( key -> oldToNewNamespaces.get( key ) + uriParts[1] );
41+
return Optional.of( newNamespace + oldUri.substring( indexOfHash + 1 ) );
4342
}
4443

4544
@Override

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/impl/DefaultScalarValue.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ public class DefaultScalarValue implements ScalarValue {
3131

3232
private final MetaModelBaseAttributes metaModelBaseAttributes;
3333

34+
/**
35+
* Constructor for non-described/anonymous scalar values
36+
*
37+
* @param value the value
38+
* @param type the type
39+
*/
40+
public DefaultScalarValue( final Object value, final Scalar type ) {
41+
this( null, value, type );
42+
}
43+
44+
/**
45+
* Standard constructor for scalar values that provides context information such as the value's descriptions
46+
*
47+
* @param metaModelBaseAttributes the base attributes
48+
* @param value the value
49+
* @param type the type
50+
*/
3451
public DefaultScalarValue( final MetaModelBaseAttributes metaModelBaseAttributes, final Object value, final Scalar type ) {
3552
this.metaModelBaseAttributes = metaModelBaseAttributes;
3653
this.value = value;
@@ -49,22 +66,22 @@ public Scalar getType() {
4966

5067
@Override
5168
public List<String> getSee() {
52-
return metaModelBaseAttributes.getSee();
69+
return metaModelBaseAttributes == null ? List.of() : metaModelBaseAttributes.getSee();
5370
}
5471

5572
@Override
5673
public Set<LangString> getPreferredNames() {
57-
return metaModelBaseAttributes.getPreferredNames();
74+
return metaModelBaseAttributes == null ? Set.of() : metaModelBaseAttributes.getPreferredNames();
5875
}
5976

6077
@Override
6178
public Set<LangString> getDescriptions() {
62-
return metaModelBaseAttributes.getDescriptions();
79+
return metaModelBaseAttributes == null ? Set.of() : metaModelBaseAttributes.getDescriptions();
6380
}
6481

6582
@Override
6683
public AspectModelFile getSourceFile() {
67-
return metaModelBaseAttributes.getSourceFile();
84+
return metaModelBaseAttributes == null ? null : metaModelBaseAttributes.getSourceFile();
6885
}
6986

7087
@Override

core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/openapi/AspectModelOpenApiGenerator.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ private void setResponseBodies( final Aspect aspect, final ObjectNode jsonNode,
248248
final ObjectNode componentsResponseNode = (ObjectNode) jsonNode.get( FIELD_COMPONENTS ).get( FIELD_RESPONSES );
249249
final ObjectNode referenceNode = FACTORY.objectNode()
250250
.put( REF, COMPONENTS_SCHEMAS + ( includePaging ? FIELD_PAGING_SCHEMA : aspect.getName() ) );
251-
final ObjectNode contentNode = getApplicationNode( referenceNode );
251+
final ObjectNode contentNode = getApplicationNode( referenceNode, false );
252252
componentsResponseNode.set( aspect.getName(), contentNode );
253253
contentNode.put( FIELD_DESCRIPTION, "The request was successful." );
254254
if ( !aspect.getOperations().isEmpty() ) {
255255
final ObjectNode operationResponseNode = FACTORY.objectNode()
256256
.put( REF, COMPONENTS_SCHEMAS + FIELD_OPERATION_RESPONSE );
257-
final ObjectNode wrappedOperationNode = getApplicationNode( operationResponseNode );
257+
final ObjectNode wrappedOperationNode = getApplicationNode( operationResponseNode, false );
258258
componentsResponseNode.set( FIELD_OPERATION_RESPONSE, wrappedOperationNode );
259259
wrappedOperationNode.put( FIELD_DESCRIPTION, "The request was successful." );
260260
}
@@ -265,21 +265,24 @@ private void setRequestBodies( final Aspect aspect, final OpenApiSchemaGeneratio
265265
final ObjectNode requestBodies = FACTORY.objectNode();
266266
componentNode.set( FIELD_REQUEST_BODIES, requestBodies );
267267
requestBodies.set( aspect.getName(),
268-
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + aspect.getName() ) ) );
268+
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + aspect.getName() ), true ) );
269269
if ( config.includeQueryApi() ) {
270270
requestBodies.set( FIELD_FILTER,
271-
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + FIELD_FILTER ) ) );
271+
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + FIELD_FILTER ), true ) );
272272
}
273273
if ( !aspect.getOperations().isEmpty() ) {
274274
requestBodies.set( FIELD_OPERATION,
275-
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + FIELD_OPERATION ) ) );
275+
getApplicationNode( FACTORY.objectNode().put( REF, COMPONENTS_SCHEMAS + FIELD_OPERATION ), true ) );
276276
}
277277
}
278278

279-
private ObjectNode getApplicationNode( final ObjectNode contentNode ) {
280-
return FACTORY.objectNode().set( FIELD_CONTENT,
281-
FACTORY.objectNode().set( APPLICATION_JSON,
282-
FACTORY.objectNode().set( FIELD_SCHEMA, contentNode ) ) );
279+
private ObjectNode getApplicationNode( final ObjectNode contentNode, final boolean addRequired ) {
280+
final ObjectNode result = FACTORY.objectNode();
281+
result.set( FIELD_CONTENT, FACTORY.objectNode().set( APPLICATION_JSON, FACTORY.objectNode().set( FIELD_SCHEMA, contentNode ) ) );
282+
if ( addRequired ) {
283+
result.put( FIELD_REQUIRED, true );
284+
}
285+
return result;
283286
}
284287

285288
private void setAspectSchemas( final Aspect aspect, final OpenApiSchemaGenerationConfig config, final ObjectNode jsonNode ) {
@@ -503,7 +506,10 @@ private ObjectNode getRequestEndpointsUpdate( final Aspect aspect, final ObjectN
503506
objectNode.set( "tags", FACTORY.arrayNode().add( aspect.getName() ) );
504507
objectNode.put( FIELD_OPERATION_ID, ( isPut ? FIELD_PUT : FIELD_PATCH ) + aspect.getName() );
505508
objectNode.set( FIELD_PARAMETERS, getRequiredParameters( parameterNode, isEmpty( resourcePath ) ) );
506-
objectNode.set( FIELD_REQUEST_BODY, FACTORY.objectNode().put( REF, COMPONENTS_REQUESTS + aspect.getName() ) );
509+
final ObjectNode requestBody = FACTORY.objectNode();
510+
requestBody.put( FIELD_REQUIRED, true );
511+
requestBody.put( REF, COMPONENTS_REQUESTS + aspect.getName() );
512+
objectNode.set( FIELD_REQUEST_BODY, requestBody );
507513
objectNode.set( FIELD_RESPONSES, getResponsesForGet( aspect ) );
508514
return objectNode;
509515
}

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/openapi/AspectModelOpenApiGeneratorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ void testAspectWithPutOperation() {
586586
final SwaggerParseResult result = new OpenAPIParser().readContents( json.toString(), null, null );
587587
final OpenAPI openApi = result.getOpenAPI();
588588

589+
assertThat( openApi.getComponents().getRequestBodies().get( "AspectWithoutSeeAttribute" ).getRequired() ).isTrue();
590+
589591
final String apiEndpoint = "/{tenant-id}/aspect-without-see-attribute";
590592

591593
assertThat( openApi.getPaths().get( apiEndpoint ).getGet() ).isNotNull();

0 commit comments

Comments
 (0)