Skip to content

Commit f0f5281

Browse files
committed
Merge branch 'main' into 756-fix-custom-resolver
2 parents 29ba35c + b036873 commit f0f5281

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private void setSchemaInformation( final Aspect aspect, final PagingOption pagin
134134
schemaNode.set( AspectModelOpenApiGenerator.FIELD_PAGING_SCHEMA, node );
135135

136136
final ObjectNode itemNode = (ObjectNode) node.get( "properties" ).get( "items" );
137-
itemNode.set( "items", FACTORY.objectNode().put( "$ref", "#/components/schemas/" + aspect.getName() ) );
137+
itemNode.put( "$ref", "#/components/schemas/" + aspect.getName() );
138138
}
139139

140140
private void validatePaging( final PagingOption definedPagingOption, final Set<PagingOption> possiblePagingOptions ) {

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,42 @@ void testAspectWithCommentForSeeAttributes() {
669669
.isEqualTo( "See: http://example.com/" );
670670
}
671671

672+
@Test
673+
void testPagingSchemaStructure() {
674+
final Aspect aspect = TestResources.load( TestAspect.ASPECT_WITH_COLLECTION ).aspect();
675+
676+
final OpenApiSchemaGenerationConfig config = OpenApiSchemaGenerationConfigBuilder.builder()
677+
.useSemanticVersion( true )
678+
.baseUrl( TEST_BASE_URL )
679+
.resourcePath( TEST_RESOURCE_PATH )
680+
.locale( Locale.ENGLISH )
681+
.build();
682+
683+
final JsonNode json = new AspectModelOpenApiGenerator( aspect, config ).getContent();
684+
final SwaggerParseResult result = new OpenAPIParser().readContents( json.toString(), null, null );
685+
final OpenAPI openApi = result.getOpenAPI();
686+
687+
Schema pagingSchema = openApi.getComponents().getSchemas().get( "PagingSchema" );
688+
assertThat( pagingSchema ).isNotNull();
689+
690+
Schema itemsProperty = (Schema) pagingSchema.getProperties().get( "items" );
691+
assertThat( itemsProperty.get$ref() )
692+
.isEqualTo( "#/components/schemas/" + aspect.getName() );
693+
694+
assertThat( itemsProperty.getType() ).isNull();
695+
assertThat( itemsProperty.getItems() ).isNull();
696+
697+
assertThat( pagingSchema.getProperties() ).containsKeys(
698+
"totalItems",
699+
"totalPages",
700+
"pageSize",
701+
"currentPage"
702+
);
703+
704+
assertThat( openApi.getComponents().getSchemas().get( aspect.getName() ) )
705+
.isNotNull();
706+
}
707+
672708
private void assertSpecificationIsValid( final JsonNode jsonNode, final String json, final Aspect aspect ) throws IOException {
673709
validateUnsupportedKeywords( jsonNode );
674710

0 commit comments

Comments
 (0)