diff --git a/openapi-cli/src/main/resources/cli-help/ballerina-openapi-sanitize.help b/openapi-cli/src/main/resources/cli-help/ballerina-openapi-sanitize.help index d2154a38a..cd5aac50d 100644 --- a/openapi-cli/src/main/resources/cli-help/ballerina-openapi-sanitize.help +++ b/openapi-cli/src/main/resources/cli-help/ballerina-openapi-sanitize.help @@ -12,9 +12,7 @@ SYNOPSIS DESCRIPTION Sanitize the OpenAPI contract file according to the best naming - practices of Ballerina. The OpenAPI contract is flatten and the type - schema names are made Ballerina friendly. The Ballerina name - extensions are added to the schemas which can not be modified + practices of Ballerina. The Ballerina name extensions are added to the schemas which can not be modified directly. diff --git a/openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java b/openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java index 01a899cd3..41d5566b4 100644 --- a/openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java +++ b/openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java @@ -136,12 +136,12 @@ private void processOperationWithInlineObjectSchema(Operation operation) { } private void processParametersWithInlineObjectSchema(List parameters) { - if (parameters == null) { + if (Objects.isNull(parameters)) { return; } for (Parameter parameter : parameters) { - if (parameter.getSchema() != null) { + if (Objects.nonNull(parameter.getSchema())) { updateInlineObjectSchema(parameter.getSchema()); } } @@ -149,14 +149,14 @@ private void processParametersWithInlineObjectSchema(List parameters) private void processResponsesWithInlineObjectSchema(Map responses) { responses.forEach((status, response) -> { - if (response.getContent() != null) { + if (Objects.nonNull(response.getContent())) { updateInlineObjectInContent(response.getContent()); } }); } private void updateInlineObjectSchema(Schema schema) { - if (schema == null) { + if (Objects.isNull(schema)) { return; } handleInlineObjectSchemaInComposedSchema(schema); @@ -175,7 +175,7 @@ private void handleInlineObjectSchemaInComposedSchema(Schema schema) { } private void processSubSchemas(List subSchemas) { - if (subSchemas != null) { + if (Objects.nonNull(subSchemas)) { subSchemas.forEach(this::updateInlineObjectSchema); } } @@ -183,7 +183,7 @@ private void processSubSchemas(List subSchemas) { private static void handleInlineObjectSchema(Schema schema) { if (isInlineObjectSchema(schema)) { Map properties = schema.getProperties(); - if (properties != null && !properties.isEmpty()) { + if (Objects.nonNull(properties) && !properties.isEmpty()) { schema.setProperties(getPropertiesWithBallerinaNameExtension(properties)); } } @@ -191,11 +191,12 @@ private static void handleInlineObjectSchema(Schema schema) { private static boolean isInlineObjectSchema(Schema schema) { return schema instanceof ObjectSchema || - (schema.getType() == null && schema.get$ref() == null && schema.getProperties() != null); + (Objects.isNull(schema.getType()) && Objects.isNull(schema.get$ref()) && + Objects.nonNull(schema.getProperties())); } private void handleInlineObjectSchemaItems(Schema schema) { - if (schema.getItems() != null) { + if (Objects.nonNull(schema.getItems())) { updateInlineObjectSchema(schema.getItems()); } } @@ -207,7 +208,7 @@ private void handleInlineObjectSchemaInAdditionalProperties(Schema schema) { } private void handleInlineObjectSchemaProperties(Schema schema) { - if (schema.getProperties() != null) { + if (Objects.nonNull(schema.getProperties())) { schema.getProperties().values().forEach(this::updateInlineObjectSchema); } }