Skip to content

Commit c7b2e4c

Browse files
authored
Merge pull request #634 from bci-oss/fix-http-response-code
Fix http error code assignment for open api generator
2 parents fde8a51 + 1686d58 commit c7b2e4c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public OpenApiSchemaArtifact apply( final Aspect aspect, final OpenApiSchemaGene
130130
final ObjectNode rootNode = getRootJsonNode( config.generateCommentForSeeAttributes() );
131131
final String apiVersion = getApiVersion( aspect, config.useSemanticVersion() );
132132

133-
((ObjectNode) rootNode.get( "info" ))
133+
( (ObjectNode) rootNode.get( "info" ) )
134134
.put( "title", aspect.getPreferredName( config.locale() ) )
135135
.put( "version", apiVersion )
136136
.put( AbstractGenerator.SAMM_EXTENSION, aspect.urn().toString() );
@@ -243,7 +243,7 @@ private String getApiVersion( final Aspect aspect, final boolean useSemanticVers
243243
private void setResponseBodies( final Aspect aspect, final ObjectNode jsonNode, final boolean includePaging ) {
244244
final ObjectNode componentsResponseNode = (ObjectNode) jsonNode.get( FIELD_COMPONENTS ).get( FIELD_RESPONSES );
245245
final ObjectNode referenceNode = FACTORY.objectNode()
246-
.put( REF, COMPONENTS_SCHEMAS + (includePaging ? FIELD_PAGING_SCHEMA : aspect.getName()) );
246+
.put( REF, COMPONENTS_SCHEMAS + ( includePaging ? FIELD_PAGING_SCHEMA : aspect.getName() ) );
247247
final ObjectNode contentNode = getApplicationNode( referenceNode );
248248
componentsResponseNode.set( aspect.getName(), contentNode );
249249
contentNode.put( FIELD_DESCRIPTION, "The request was successful." );
@@ -497,7 +497,7 @@ private ObjectNode getRequestEndpointsUpdate( final Aspect aspect, final ObjectN
497497
final boolean isPut ) {
498498
final ObjectNode objectNode = FACTORY.objectNode();
499499
objectNode.set( "tags", FACTORY.arrayNode().add( aspect.getName() ) );
500-
objectNode.put( FIELD_OPERATION_ID, (isPut ? FIELD_PUT : FIELD_PATCH) + aspect.getName() );
500+
objectNode.put( FIELD_OPERATION_ID, ( isPut ? FIELD_PUT : FIELD_PATCH ) + aspect.getName() );
501501
objectNode.set( FIELD_PARAMETERS, getRequiredParameters( parameterNode, isEmpty( resourcePath ) ) );
502502
objectNode.set( FIELD_REQUEST_BODY, FACTORY.objectNode().put( REF, COMPONENTS_REQUESTS + aspect.getName() ) );
503503
objectNode.set( FIELD_RESPONSES, getResponsesForGet( aspect ) );
@@ -516,8 +516,8 @@ private void setErrorResponses( final ObjectNode responses ) {
516516
final ObjectNode unauthorized = FACTORY.objectNode().put( REF, COMPONENTS_RESPONSES + UNAUTHORIZED );
517517
final ObjectNode forbidden = FACTORY.objectNode().put( REF, COMPONENTS_RESPONSES + FORBIDDEN );
518518
final ObjectNode notFoundError = FACTORY.objectNode().put( REF, COMPONENTS_RESPONSES + NOT_FOUND_ERROR );
519-
responses.set( "401", clientError );
520-
responses.set( "402", unauthorized );
519+
responses.set( "400", clientError );
520+
responses.set( "401", unauthorized );
521521
responses.set( "403", forbidden );
522522
responses.set( "404", notFoundError );
523523
}

core/esmf-aspect-model-document-generators/src/main/resources/openapi/OpenApiRootJson.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"description": "The requesting user or client is not authenticated."
5353
},
5454
"Forbidden": {
55-
"description": "The requesting user or client is not authorized to access resources for the given tenant."
55+
"description": "The requesting user or client is not authorized to access resources."
5656
},
5757
"NotFoundError": {
58-
"description": "The requested Twin has not been found."
58+
"description": "The requested resource has not been found."
5959
},
6060
"ClientError": {
61-
"description": "Payload or user input is invalid. See error details in the payload for more.",
61+
"description": "Payload or user input is invalid. See error details in the payload for more information.",
6262
"content": {
6363
"application/json": {
6464
"schema": {

0 commit comments

Comments
 (0)