Skip to content

Commit

Permalink
Fix review suggestions and conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lnash94 committed Oct 20, 2023
1 parent 5763d6c commit bf1cdbc
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum DiagnosticMessages {
"for Ballerina type '%s'. ", DiagnosticSeverity.WARNING),
OAS_CONVERTOR_115("OAS_CONVERTOR_115", "Given Ballerina file does not contain any HTTP service.",
DiagnosticSeverity.ERROR),
OAS_CONVERTOR_116("OAS_CONVERTOR_116", "Failed to parser the Number value due to: %s ",
OAS_CONVERTOR_116("OAS_CONVERTOR_116", "Failed to parse the Number value due to: %s ",
DiagnosticSeverity.ERROR),
OAS_CONVERTOR_117("OAS_CONVERTOR_117", "Generated OpenAPI definition does not contain `%s` request" +
" body information, as it's not supported by the OpenAPI tool.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.ballerina.compiler.syntax.tree.TypeDefinitionNode;

import java.util.LinkedHashSet;
import java.util.Set;

/**
* Visitor to get the TypeDefinitionNode and ListenerDeclarationNodes.
Expand All @@ -31,8 +32,8 @@
*/
public class ModuleMemberVisitor extends NodeVisitor {

LinkedHashSet<TypeDefinitionNode> typeDefinitionNodes = new LinkedHashSet<>();
LinkedHashSet<ListenerDeclarationNode> listenerDeclarationNodes = new LinkedHashSet<>();
Set<TypeDefinitionNode> typeDefinitionNodes = new LinkedHashSet<>();
Set<ListenerDeclarationNode> listenerDeclarationNodes = new LinkedHashSet<>();

@Override
public void visit(TypeDefinitionNode typeDefinitionNode) {
Expand All @@ -44,11 +45,11 @@ public void visit(ListenerDeclarationNode listenerDeclarationNode) {
listenerDeclarationNodes.add(listenerDeclarationNode);
}

public LinkedHashSet<TypeDefinitionNode> getTypeDefinitionNodes() {
public Set<TypeDefinitionNode> getTypeDefinitionNodes() {
return typeDefinitionNodes;
}

public LinkedHashSet<ListenerDeclarationNode> getListenerDeclarationNodes() {
public Set<ListenerDeclarationNode> getListenerDeclarationNodes() {
return listenerDeclarationNodes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.Spliterator;

import static io.ballerina.openapi.converter.Constants.DOUBLE;
Expand All @@ -92,7 +92,7 @@ public class OpenAPIComponentMapper {
private final Components components;
private final List<OpenAPIConverterDiagnostic> diagnostics;
private final HashSet<String> visitedTypeDefinitionNames = new HashSet<>();
private final LinkedHashSet<TypeDefinitionNode> typeDefinitionNodes;
private final Set<TypeDefinitionNode> typeDefinitionNodes;

public OpenAPIComponentMapper(Components components, ModuleMemberVisitor moduleMemberVisitor) {
this.components = components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static io.ballerina.openapi.converter.Constants.PORT;
import static io.ballerina.openapi.converter.Constants.SERVER;
Expand All @@ -66,7 +66,7 @@ public class OpenAPIEndpointMapper {
* @param service service node with bound endpoints
* @return openapi definition with Server information
*/
public OpenAPI getServers(OpenAPI openAPI, LinkedHashSet<ListenerDeclarationNode> endpoints,
public OpenAPI getServers(OpenAPI openAPI, Set<ListenerDeclarationNode> endpoints,
ServiceDeclarationNode service) {
openAPI = extractServerForExpressionNode(openAPI, service.expressions(), service);
List<Server> servers = openAPI.getServers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import static io.ballerina.openapi.converter.Constants.CONTRACT;
import static io.ballerina.openapi.converter.Constants.HYPHEN;
Expand Down Expand Up @@ -204,7 +204,7 @@ private static void extractServiceNodes(String serviceName, List<String> availab
public static OASResult generateOAS(OASGenerationMetaInfo oasGenerationMetaInfo) {
ServiceDeclarationNode serviceDefinition = oasGenerationMetaInfo.getServiceDeclarationNode();
ModuleMemberVisitor moduleMemberVisitor = extractNodesFromProject(oasGenerationMetaInfo.getProject());
LinkedHashSet<ListenerDeclarationNode> listeners = moduleMemberVisitor.getListenerDeclarationNodes();
Set<ListenerDeclarationNode> listeners = moduleMemberVisitor.getListenerDeclarationNodes();
SemanticModel semanticModel = oasGenerationMetaInfo.getSemanticModel();
String openApiFileName = oasGenerationMetaInfo.getOpenApiFileName();
Path ballerinaFilePath = oasGenerationMetaInfo.getBallerinaFilePath();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ service /payloadV on new http:Listener(9090) {
resource function post pet(@http:Payload Person body) returns error? {
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Person'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/School'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/School'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Hotel'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down Expand Up @@ -55,10 +59,10 @@ components:
minimum: 2.5
type: number
format: float
Hotel:
required:
- rate
type: object
properties:
rate:
$ref: '#/components/schemas/Rating'
Hotel:
required:
- rate
type: object
properties:
rate:
$ref: '#/components/schemas/Rating'
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Hotel'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down Expand Up @@ -55,10 +59,10 @@ components:
exclusiveMinimum: true
type: number
format: float
Hotel:
required:
- rate
type: object
properties:
rate:
$ref: '#/components/schemas/Rating'
Hotel:
required:
- rate
type: object
properties:
rate:
$ref: '#/components/schemas/Rating'
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Child'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Child'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ paths:
schema:
$ref: '#/components/schemas/Person'
responses:
"202":
description: Accepted
"400":
description: BadRequest
"500":
description: Internal server error
content:
Expand Down

0 comments on commit bf1cdbc

Please sign in to comment.