Repository: ballerina-platform/openapi-tools
Issue: OpenAPI LS Extension returns wrong response without running the code modifier

**Description:**

We have introduced a default http payload parameter support in 2201.5.x. It automatically adds the payload annotation to a compatible signature parameter type using the code modifier. This change has been adhered to open API-tools by running the code modifiers before generating the document. But seems like we have missed adding this to the LS extension which is used for `Try it` feature in the VS code.

**Steps to reproduce:**

Use the [following BBE ](https://ballerina.io/learn/by-example/http-service-data-binding/)in the VS code and click on the `Try it` option to see the openAPI. The parameter is shown as a query parameter.

This `Try it` feature uses the `openAPILSExtension/generateOpenAPI` API to generate the openAPI. 

**Affected Versions:**

2201.5.x, 2201.6.0



Changed files:
openapi-ls-extension/src/main/java/io/ballerina/openapi/extension/OpenAPIConverterService.java

diff --git a/openapi-ls-extension/src/main/java/io/ballerina/openapi/extension/OpenAPIConverterService.java b/openapi-ls-extension/src/main/java/io/ballerina/openapi/extension/OpenAPIConverterService.java
index 7015c08b..c098b301 100644
--- a/openapi-ls-extension/src/main/java/io/ballerina/openapi/extension/OpenAPIConverterService.java
+++ b/openapi-ls-extension/src/main/java/io/ballerina/openapi/extension/OpenAPIConverterService.java
@@ -30,10 +30,10 @@ import io.ballerina.compiler.syntax.tree.SyntaxTree;
 import io.ballerina.openapi.converter.diagnostic.OpenAPIConverterDiagnostic;
 import io.ballerina.openapi.converter.model.OASResult;
 import io.ballerina.openapi.converter.utils.ServiceToOpenAPIConverterUtils;
+import io.ballerina.projects.DiagnosticResult;
 import io.ballerina.projects.Document;
 import io.ballerina.projects.DocumentId;
 import io.ballerina.projects.Module;
-import io.ballerina.projects.Package;
 import io.ballerina.projects.Project;
 import io.ballerina.tools.diagnostics.Diagnostic;
 import io.ballerina.tools.diagnostics.DiagnosticSeverity;
@@ -136,16 +136,21 @@ public class OpenAPIConverterService implements ExtendedLanguageServerService {
                 response.setError("Error while getting the project.");
                 return response;
             }
-            Package aPackage = module.get().currentPackage();
-            Collection<Diagnostic> diagnostics = aPackage.getCompilation().diagnosticResult().diagnostics();
-            boolean hasErrors = diagnostics.stream()
+            DiagnosticResult diagnosticsFromCodeGenAndModify = module.get()
+                    .currentPackage()
+                    .runCodeGenAndModifyPlugins();
+            boolean hasErrorsFromCodeGenAndModify = diagnosticsFromCodeGenAndModify.diagnostics().stream()
                     .anyMatch(d -> DiagnosticSeverity.ERROR.equals(d.diagnosticInfo().severity()));
-            if (hasErrors) {
+            Collection<Diagnostic> compilationDiagnostics = module.get().currentPackage()
+                    .getCompilation().diagnosticResult().diagnostics();
+            boolean hasCompilationErrors = compilationDiagnostics.stream()
+                    .anyMatch(d -> DiagnosticSeverity.ERROR.equals(d.diagnosticInfo().severity()));
+            if (hasCompilationErrors || hasErrorsFromCodeGenAndModify) {
                 // if there are any compilation errors, do not proceed
                 response.setError("Given Ballerina file contains compilation error(s).");
                 return response;
             }
-            Module defaultModule = aPackage.getDefaultModule();
+            Module defaultModule = module.get().currentPackage().getDefaultModule();
 
             JsonArray specs = new JsonArray();
             for (DocumentId currentDocumentID : defaultModule.documentIds()) {