diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/config.yaml b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/config.yaml deleted file mode 100644 index 06f1b3c5f..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -files: - api.mustache: - destinationFilename: {{src}}/Api.java - templateType: SupportingFiles - apiProps.mustache: - destinationFilename: {{src}}/ApiProps.java - templateType: SupportingFiles - mockIntegrations.mustache: - destinationFilename: {{src}}/MockIntegrations.java - templateType: SupportingFiles - functions.handlebars: - destinationFilename: {{src}}/__functions.java - templateType: SupportingFiles diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.ejs similarity index 91% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.mustache rename to packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.ejs index 405a4740c..594999f7f 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.mustache +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/api.ejs @@ -1,11 +1,19 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; +###TSAPI_WRITE_FILE### +{ + "id": "api", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "Api", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; import com.fasterxml.jackson.databind.ObjectMapper; import software.aws.pdk.type_safe_api.OperationDetails; import software.aws.pdk.type_safe_api.TypeSafeRestApi; import software.aws.pdk.type_safe_api.TypeSafeRestApiProps; import software.constructs.Construct; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationLookup; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationLookup; import java.io.IOException; import java.net.URL; diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.ejs similarity index 84% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.mustache rename to packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.ejs index 4379ecf9b..8d96b866f 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.mustache +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.ejs @@ -1,4 +1,12 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; +###TSAPI_WRITE_FILE### +{ + "id": "api-props", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "ApiProps", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; import software.amazon.awscdk.services.apigateway.CorsOptions; import software.amazon.awscdk.services.apigateway.StageOptions; @@ -11,7 +19,7 @@ import software.aws.pdk.type_safe_api.Authorizer; import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; import software.aws.pdk.type_safe_api.TypeSafeApiWebAclOptions; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationConfig; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationConfig; import java.util.List; import java.util.Map; diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.ejs similarity index 57% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.handlebars rename to packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.ejs index dd8a54dec..9b6c08919 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.handlebars +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.ejs @@ -1,17 +1,17 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} +<%_ allOperations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler']) { _%> +<%_ const language = operation.vendorExtensions['x-handler'].language; _%> +<%_ const isTypeScript = language === 'typescript'; _%> +<%_ const isJava = language === 'java'; _%> +<%_ const isPython = language === 'python'; _%> ###TSAPI_WRITE_FILE### { - "dir": "functions", - "name": "{{operationIdCamelCase}}Function", + "dir": "<%= metadata.srcDir || 'src' %>/functions", + "name": "<%- operation.operationIdPascalCase %>Function", "ext": ".java", "overwrite": true } -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}.functions; +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>.functions; import org.jetbrains.annotations.NotNull; import software.amazon.awscdk.services.lambda.Function; @@ -19,25 +19,25 @@ import software.aws.pdk.type_safe_api.SnapStartFunction; import software.constructs.Construct; /** - * Lambda function construct which points to the {{vendorExtensions.x-handler.language}} implementation of {{operationIdCamelCase}} + * Lambda function construct which points to the <%- language %> implementation of <%- operation.operationIdPascalCase %> */ -public class {{operationIdCamelCase}}Function extends {{#startsWith vendorExtensions.x-handler.language 'java' ~}}SnapStart{{~/startsWith}}Function { - public {{operationIdCamelCase}}Function(@NotNull Construct scope, @NotNull String id, @NotNull {{operationIdCamelCase}}FunctionProps props) { +public class <%- operation.operationIdPascalCase %>Function extends <% if (isJava) { %>SnapStart<% } %>Function { + public <%- operation.operationIdPascalCase %>Function(@NotNull Construct scope, @NotNull String id, @NotNull <%- operation.operationIdPascalCase %>FunctionProps props) { super(scope, id, props); } - public {{operationIdCamelCase}}Function(@NotNull Construct scope, @NotNull String id) { - this(scope, id, {{operationIdCamelCase}}FunctionProps.builder().build()); + public <%- operation.operationIdPascalCase %>Function(@NotNull Construct scope, @NotNull String id) { + this(scope, id, <%- operation.operationIdPascalCase %>FunctionProps.builder().build()); } } ###TSAPI_WRITE_FILE### { - "dir": "functions", - "name": "{{operationIdCamelCase}}FunctionProps", + "dir": "<%= metadata.srcDir || 'src' %>/functions", + "name": "<%- operation.operationIdPascalCase %>FunctionProps", "ext": ".java", "overwrite": true } -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}.functions; +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>.functions; import org.jetbrains.annotations.NotNull; import software.amazon.awscdk.Duration; @@ -79,12 +79,12 @@ import java.util.List; import java.util.Map; @lombok.Builder @lombok.Getter -public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vendorExtensions.x-handler.language 'java' ~}}SnapStart{{~/startsWith}}FunctionProps { +public class <%- operation.operationIdPascalCase %>FunctionProps implements <% if (isJava) { %>SnapStart<% } %>FunctionProps { private static String infraProjectAbsolutePath; static { try { - try (InputStream stream = {{operationIdCamelCase}}FunctionProps.class.getClassLoader() + try (InputStream stream = <%- operation.operationIdPascalCase %>FunctionProps.class.getClassLoader() .getResourceAsStream("project-absolute-path.txt")) { try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { infraProjectAbsolutePath = new BufferedReader(inputStreamReader).lines().findFirst() @@ -98,28 +98,28 @@ public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vend // Fixed props private final Code code = Code.fromAsset(Paths.get(infraProjectAbsolutePath).resolve( - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-typescript-asset-path}}{{/apis.0}}{{/apiInfo}}/###TSAPI_FN###{ "function": "kebabCase", "args": ["{{operationIdCamelCase}}"] }###/TSAPI_FN###" - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-asset-path}}{{/apis.0}}{{/apiInfo}}" - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-asset-path}}{{/apis.0}}{{/apiInfo}}" - {{~/startsWith}} + <%_ if (isTypeScript) { _%> + "<%- metadata['x-handlers-typescript-asset-path'] %>/<%- operation.operationIdKebabCase %>" + <%_ } else if (isPython) { _%> + "<%- metadata['x-handlers-python-asset-path'] %>" + <%_ } else if (isJava) { _%> + "<%- metadata['x-handlers-java-asset-path'] %>" + <%_ } _%> ).toAbsolutePath().toString()); - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} + <%_ if (isTypeScript) { _%> private final String handler = "index.handler"; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - private final String handler = "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-module}}{{/apis.0}}{{/apiInfo}}.{{operationIdSnakeCase}}.handler"; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - private final String handler = "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-package}}{{/apis.0}}{{/apiInfo}}.{{operationIdCamelCase}}Handler"; - {{~/startsWith}} - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-node-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}} + <%_ } else if (isPython) { _%> + private final String handler = "<%- metadata['x-handlers-python-module'] %>.<%- operation.operationIdSnakeCase %>.handler"; + <%_ } else if (isJava) { _%> + private final String handler = "<%- metadata['x-handlers-java-package'] %>.<%- operation.operationIdPascalCase %>Handler"; + <%_ } _%> + <%_ if (isTypeScript) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-node-lambda-runtime-version'] %>; + <%_ } else if (isPython) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-python-lambda-runtime-version'] %>; + <%_ } else if (isJava) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-java-lambda-runtime-version'] %>; + <%_ } _%> // Props with defaults @lombok.Builder.Default @@ -165,8 +165,5 @@ public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vend IDestination onSuccess; Number retryAttempts; } -{{/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file +<%_ } _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.ejs new file mode 100644 index 000000000..5a895c635 --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.ejs @@ -0,0 +1,108 @@ +###TSAPI_WRITE_FILE### +{ + "id": "mock-integrations", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "MockIntegrations", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.JSON; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationConfig; +import <%- metadata.runtimePackageName %>.model.*; +import software.aws.pdk.type_safe_api.Integrations; +import software.aws.pdk.type_safe_api.MockIntegration; +import software.aws.pdk.type_safe_api.MockIntegrationResponse; +import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.file.Paths; +import java.util.stream.Collectors; + + +/** + * Type-safe mock integrations for API operations + */ +public class MockIntegrations { + static { + // Instantiate json instance so that any .toJson() methods can be used + new JSON(); + } + + /** + * Read a mock data file for the given operation + */ + private static String readMockDataFile(final String method, final String path, final int statusCode) { + try { + try (InputStream stream = MockIntegrations.class.getClassLoader() + .getResourceAsStream(Paths.get("mocks", method + path.replaceAll("/", "-") + String.format("-%d.json", statusCode)).toString())) { + try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { + return new BufferedReader(inputStreamReader).lines().collect(Collectors.joining(System.lineSeparator())); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + <%_ if (metadata.enableMockIntegrations) { _%> + <%_ allOperations.forEach((operation) => { _%> + <%_ operation.responses.forEach((response) => { _%> + /** + * Mock integration to return a <%- response.code %> response from the <%- operation.name %> operation + */ + public static MockIntegration <%- operation.name %><%- response.code %>(<% if (response.type !== 'void') { %>final <% if (response.isPrimitive) { %>String<% } else { %><%- response.javaType %><% } %> body<% } %>) { + return Integrations.mock(MockIntegrationResponse.builder() + .statusCode(<%- response.code %>) + <%_ if (response.type !== 'void') { _%> + <%_ if (response.isPrimitive) { _%> + .body(body) + <%_ } else { _%> + .body(body.toJson()) + <%_ } _%> + <%_ } _%> + .build()); + } + <%_ if (response.type !== 'void') { _%> + <%_ if (!response.isPrimitive) { _%> + + /** + * Mock integration to return a <%- response.code %> response from the <%- operation.name %> operation, with generated mock data + */ + public static MockIntegration <%- operation.name %><%- response.code %>() { + return Integrations.mock(MockIntegrationResponse.builder() + .statusCode(<%- response.code %>) + .body(MockIntegrations.readMockDataFile("<%- operation.method.toLowerCase() %>", "<%- operation.path %>", <%- response.code %>)) + .build()); + } + <%_ } _%> + <%_ } _%> + + <%_ }); _%> + <%_ }); _%> + + /** + * Mock all operations for which generated JSON data can be returned. + * The first available response is used for each operation. In most cases this is the successful 200 response. + * @return a builder which you can use to override integrations for operations before calling .build() + */ + public static OperationConfig.OperationConfigBuilder mockAll() { + return OperationConfig.builder() + <%_ allOperations.forEach((operation) => { _%> + <%_ const firstResponse = operation.results[0] || operation.responses[0]; _%> + <%_ if (firstResponse && !firstResponse.isPrimitive) { _%> + .<%- operation.name %>(TypeSafeApiIntegration.builder() + .integration(MockIntegrations.<%- operation.name %><%- firstResponse.code %>()) + .build()) + <%_ } _%> + <%_ }); _%> + ; + } + <%_ } else { _%> + // No mock integrations have been generated, since mock data generation is disabled. + <%_ } _%> +} diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.mustache deleted file mode 100644 index fbc620af7..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/mockIntegrations.mustache +++ /dev/null @@ -1,117 +0,0 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.JSON; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationConfig; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.model.*; -import software.aws.pdk.type_safe_api.Integrations; -import software.aws.pdk.type_safe_api.MockIntegration; -import software.aws.pdk.type_safe_api.MockIntegrationResponse; -import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.file.Paths; -import java.util.stream.Collectors; - - -/** - * Type-safe mock integrations for API operations - */ -public class MockIntegrations { - static { - // Instantiate json instance so that any .toJson() methods can be used - new JSON(); - } - - /** - * Read a mock data file for the given operation - */ - private static String readMockDataFile(final String method, final String path, final int statusCode) { - try { - try (InputStream stream = MockIntegrations.class.getClassLoader() - .getResourceAsStream(Paths.get("mocks", method + path.replaceAll("/", "-") + String.format("-%d.json", statusCode)).toString())) { - try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { - return new BufferedReader(inputStreamReader).lines().collect(Collectors.joining(System.lineSeparator())); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - {{#apiInfo}}{{#apis.0}}{{#vendorExtensions.x-enable-mock-integrations}} - {{#apiInfo}} - {{#apis}} - {{#operations}} - {{#operation}} - {{#responses}} - /** - * Mock integration to return a {{code}} response from the {{nickname}} operation - */ - public static MockIntegration {{nickname}}{{code}}({{#dataType}}final {{#isPrimitiveType}}String{{/isPrimitiveType}}{{^isPrimitiveType}}{{.}}{{/isPrimitiveType}} body{{/dataType}}) { - return Integrations.mock(MockIntegrationResponse.builder() - .statusCode({{code}}) - {{#dataType}} - {{#isPrimitiveType}} - .body(body) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - .body(body.toJson()) - {{/isPrimitiveType}} - {{/dataType}} - .build()); - } - {{#dataType}} - {{^isPrimitiveType}} - - /** - * Mock integration to return a {{code}} response from the {{nickname}} operation, with generated mock data - */ - public static MockIntegration {{nickname}}{{code}}() { - return Integrations.mock(MockIntegrationResponse.builder() - .statusCode({{code}}) - .body(MockIntegrations.readMockDataFile("{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}", "{{path}}", {{code}})) - .build()); - } - {{/isPrimitiveType}} - {{/dataType}} - - {{/responses}} - {{/operation}} - {{/operations}} - {{/apis}} - {{/apiInfo}} - - /** - * Mock all operations for which generated JSON data can be returned. - * The first available response is used for each operation. In most cases this is the successful 200 response. - * @return a builder which you can use to override integrations for operations before calling .build() - */ - public static OperationConfig.OperationConfigBuilder mockAll() { - return OperationConfig.builder() - {{#apiInfo}} - {{#apis}} - {{#operations}} - {{#operation}} - {{#responses.0}} - {{#dataType}} - {{^isPrimitiveType}} - .{{nickname}}(TypeSafeApiIntegration.builder() - .integration(MockIntegrations.{{nickname}}{{code}}()) - .build()) - {{/isPrimitiveType}} - {{/dataType}} - {{/responses.0}} - {{/operation}} - {{/operations}} - {{/apis}} - {{/apiInfo}} - ; - } - {{/vendorExtensions.x-enable-mock-integrations}}{{/apis.0}}{{/apiInfo}} - {{#apiInfo}}{{#apis.0}}{{^vendorExtensions.x-enable-mock-integrations}} - // No mock integrations have been generated, since mock data generation is disabled. - {{/vendorExtensions.x-enable-mock-integrations}}{{/apis.0}}{{/apiInfo}} -} diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/config.yaml b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/config.yaml deleted file mode 100644 index 2de3db934..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -files: - handlers.handlebars: - destinationFilename: {{src}}/__all_handlers.java - templateType: SupportingFiles - tests.handlebars: - destinationFilename: {{tst}}/__all_tests.java - templateType: SupportingFiles diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.ejs new file mode 100644 index 000000000..d2dfb0544 --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.ejs @@ -0,0 +1,81 @@ +<%_ services.forEach((service) => { _%> +<%_ service.operations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler'] && operation.vendorExtensions['x-handler'].language === 'java') { _%> +###TSAPI_WRITE_FILE### +{ + "id": "<%- operation.name %>", + "dir": "<%- metadata.srcDir || 'src' %>", + "name": "<%- operation.operationIdPascalCase %>Handler", + "ext": ".java", + "overwrite": false +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.api.interceptors.DefaultInterceptors; +import <%- metadata.runtimePackageName %>.api.handlers.Interceptor; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Input; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>500Response; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestInput; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Response; +import <%- metadata.runtimePackageName %>.model.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.List; + +/** + * Entry point for the AWS Lambda handler for the <%- operation.operationIdPascalCase %> operation. + * The <%- operation.operationIdPascalCase %> class manages marshalling inputs and outputs. + */ +public class <%- operation.operationIdPascalCase %>Handler extends <%- operation.operationIdPascalCase %> { + /** + * Interceptors are initialised once during the lambda "init" phase + */ + private final ListInput>> interceptors = DefaultInterceptors.all(); + + /** + * Use the logger to log requests. The LoggingInterceptor sets up all loggers to include lambda context values in your logs. + */ + private final Logger log = LogManager.getLogger(<%- operation.operationIdPascalCase %>Handler.class); + + /** + * Return the interceptors for this handler. + * You can also use the @Interceptors annotation on the class to add interceptors + */ + @Override + public ListInput>> getInterceptors() { + return this.interceptors; + } + + /** + * This method is executed prior to the Java SnapStart snapshot being taken. + * Perform any warmup activities to "prime" your function here. Code in this function will be just-in-time compiled, + * before the snapshot is taken, and thus optimised ready for the first invocation. + * For example if your function interacts with DynamoDB, perform a simple read operation here. + * @see https://aws.amazon.com/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ + */ + @Override + public void warmUp() { + + } + + /** + * Type-safe handler for the <%- operation.operationIdPascalCase %> operation + */ + @Override + public <%- operation.operationIdPascalCase %>Response handle(final <%- operation.operationIdPascalCase %>RequestInput request) { + log.info("Start <%- operation.operationIdPascalCase %> Operation"); + + // TODO: Implement <%- operation.operationIdPascalCase %> Operation. `input` contains the request input. + <%- operation.operationIdPascalCase %>Input input = request.getInput(); + + return <%- operation.operationIdPascalCase %>500Response.of(InternalFailureErrorResponseContent.builder() + .message("Not Implemented!") + .build()); + } +} + +<%_ } _%> +<%_ }); _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.handlebars deleted file mode 100644 index aa68c9ee1..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/handlers.handlebars +++ /dev/null @@ -1,88 +0,0 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} -{{#startsWith vendorExtensions.x-handler.language 'java'}} -###TSAPI_WRITE_FILE### -{ - "id": "{{operationIdCamelCase}}Handler", - "dir": ".", - "name": "{{operationIdCamelCase}}Handler", - "ext": ".java", - "overwrite": false -} -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.interceptors.DefaultInterceptors; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.Interceptor; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Input; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}500Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestInput; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.model.*; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.List; - -/** - * Entry point for the AWS Lambda handler for the {{operationIdCamelCase}} operation. - * The {{operationIdCamelCase}} class manages marshalling inputs and outputs. - */ -public class {{operationIdCamelCase}}Handler extends {{operationIdCamelCase}} { - /** - * Interceptors are initialised once during the lambda "init" phase - */ - private final List> interceptors = DefaultInterceptors.all(); - - /** - * Use the logger to log requests. The LoggingInterceptor sets up all loggers to include lambda context values in your logs. - */ - private final Logger log = LogManager.getLogger({{operationIdCamelCase}}Handler.class); - - /** - * Return the interceptors for this handler. - * You can also use the @Interceptors annotation on the class to add interceptors - */ - @Override - public List> getInterceptors() { - return this.interceptors; - } - - /** - * This method is executed prior to the Java SnapStart snapshot being taken. - * Perform any warmup activities to "prime" your function here. Code in this function will be just-in-time compiled, - * before the snapshot is taken, and thus optimised ready for the first invocation. - * For example if your function interacts with DynamoDB, perform a simple read operation here. - * @see https://aws.amazon.com/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ - */ - @Override - public void warmUp() { - - } - - /** - * Type-safe handler for the {{operationIdCamelCase}} operation - */ - @Override - public {{operationIdCamelCase}}Response handle(final {{operationIdCamelCase}}RequestInput request) { - log.info("Start {{operationIdCamelCase}} Operation"); - - // TODO: Implement {{operationIdCamelCase}} Operation. `input` contains the request input. - {{operationIdCamelCase}}Input input = request.getInput(); - - return {{operationIdCamelCase}}500Response.of(InternalFailureErrorResponseContent.builder() - .message("Not Implemented!") - .build()); - } -} - -{{~/startsWith}} -{{~/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.ejs new file mode 100644 index 000000000..a777c620a --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.ejs @@ -0,0 +1,50 @@ +<%_ services.forEach((service) => { _%> +<%_ service.operations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler'] && operation.vendorExtensions['x-handler'].language === 'java') { _%> +###TSAPI_WRITE_FILE### +{ + "id": "<%- operation.name %>Test", + "dir": "<%- metadata.tstDir || 'tst' %>", + "name": "<%- operation.operationIdPascalCase %>HandlerTest", + "ext": ".java", + "generateConditionallyId": "<%- operation.name %>" +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Input; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>500Response; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestInput; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestParameters; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Response; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for <%- operation.operationIdPascalCase %>Handler + */ +public class <%- operation.operationIdPascalCase %>HandlerTest { + @Test + public void shouldReturnNotImplementedError() { + // TODO: Update the test as appropriate when you implement your handler + <%- operation.operationIdPascalCase %>Response response = new <%- operation.operationIdPascalCase %>Handler().handle(<%- operation.operationIdPascalCase %>RequestInput.builder() + .interceptorContext(new HashMap<>()) + .input(<%- operation.operationIdPascalCase %>Input.builder() + .requestParameters(<%- operation.operationIdPascalCase %>RequestParameters.builder() + // Add request parameters here... + .build()) + // If the request has a body you can add it here... + .build()) + .build()); + assertEquals(500, response.getStatusCode()); + + // Cast to the particular type of response returned to access the typed response body + assertEquals("Not Implemented!", ((<%- operation.operationIdPascalCase %>500Response) response).getTypedBody().getMessage()); + } +} + +<%_ } _%> +<%_ }); _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.handlebars deleted file mode 100644 index 13e6751ed..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-lambda-handlers/templates/tests.handlebars +++ /dev/null @@ -1,57 +0,0 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} -{{#startsWith vendorExtensions.x-handler.language 'java'}} -###TSAPI_WRITE_FILE### -{ - "id": "{{operationIdCamelCase}}HandlerTest", - "dir": ".", - "name": "{{operationIdCamelCase}}HandlerTest", - "ext": ".java", - "generateConditionallyId": "{{operationIdCamelCase}}Handler" -} -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Input; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}500Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestInput; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestParameters; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Response; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Tests for {{operationIdCamelCase}}Handler - */ -public class {{operationIdCamelCase}}HandlerTest { - @Test - public void shouldReturnNotImplementedError() { - // TODO: Update the test as appropriate when you implement your handler - {{operationIdCamelCase}}Response response = new {{operationIdCamelCase}}Handler().handle({{operationIdCamelCase}}RequestInput.builder() - .interceptorContext(new HashMap<>()) - .input({{operationIdCamelCase}}Input.builder() - .requestParameters({{operationIdCamelCase}}RequestParameters.builder() - // Add request parameters here... - .build()) - // If the request has a body you can add it here... - .build()) - .build()); - assertEquals(500, response.getStatusCode()); - - // Cast to the particular type of response returned to access the typed response body - assertEquals("Not Implemented!", (({{operationIdCamelCase}}500Response) response).getTypedBody().getMessage()); - } -} - -{{~/startsWith}} -{{~/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/config.yaml b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/config.yaml deleted file mode 100644 index 06f1b3c5f..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -files: - api.mustache: - destinationFilename: {{src}}/Api.java - templateType: SupportingFiles - apiProps.mustache: - destinationFilename: {{src}}/ApiProps.java - templateType: SupportingFiles - mockIntegrations.mustache: - destinationFilename: {{src}}/MockIntegrations.java - templateType: SupportingFiles - functions.handlebars: - destinationFilename: {{src}}/__functions.java - templateType: SupportingFiles diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.ejs similarity index 91% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.mustache rename to packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.ejs index 405a4740c..594999f7f 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.mustache +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/api.ejs @@ -1,11 +1,19 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; +###TSAPI_WRITE_FILE### +{ + "id": "api", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "Api", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; import com.fasterxml.jackson.databind.ObjectMapper; import software.aws.pdk.type_safe_api.OperationDetails; import software.aws.pdk.type_safe_api.TypeSafeRestApi; import software.aws.pdk.type_safe_api.TypeSafeRestApiProps; import software.constructs.Construct; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationLookup; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationLookup; import java.io.IOException; import java.net.URL; diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.ejs similarity index 84% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.mustache rename to packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.ejs index 4379ecf9b..8d96b866f 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/apiProps.mustache +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/apiProps.ejs @@ -1,4 +1,12 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; +###TSAPI_WRITE_FILE### +{ + "id": "api-props", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "ApiProps", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; import software.amazon.awscdk.services.apigateway.CorsOptions; import software.amazon.awscdk.services.apigateway.StageOptions; @@ -11,7 +19,7 @@ import software.aws.pdk.type_safe_api.Authorizer; import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; import software.aws.pdk.type_safe_api.TypeSafeApiWebAclOptions; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationConfig; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationConfig; import java.util.List; import java.util.Map; diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.ejs similarity index 57% rename from packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.handlebars rename to packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.ejs index dd8a54dec..9b6c08919 100644 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-async-cdk-infrastructure/templates/functions.handlebars +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/functions.ejs @@ -1,17 +1,17 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} +<%_ allOperations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler']) { _%> +<%_ const language = operation.vendorExtensions['x-handler'].language; _%> +<%_ const isTypeScript = language === 'typescript'; _%> +<%_ const isJava = language === 'java'; _%> +<%_ const isPython = language === 'python'; _%> ###TSAPI_WRITE_FILE### { - "dir": "functions", - "name": "{{operationIdCamelCase}}Function", + "dir": "<%= metadata.srcDir || 'src' %>/functions", + "name": "<%- operation.operationIdPascalCase %>Function", "ext": ".java", "overwrite": true } -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}.functions; +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>.functions; import org.jetbrains.annotations.NotNull; import software.amazon.awscdk.services.lambda.Function; @@ -19,25 +19,25 @@ import software.aws.pdk.type_safe_api.SnapStartFunction; import software.constructs.Construct; /** - * Lambda function construct which points to the {{vendorExtensions.x-handler.language}} implementation of {{operationIdCamelCase}} + * Lambda function construct which points to the <%- language %> implementation of <%- operation.operationIdPascalCase %> */ -public class {{operationIdCamelCase}}Function extends {{#startsWith vendorExtensions.x-handler.language 'java' ~}}SnapStart{{~/startsWith}}Function { - public {{operationIdCamelCase}}Function(@NotNull Construct scope, @NotNull String id, @NotNull {{operationIdCamelCase}}FunctionProps props) { +public class <%- operation.operationIdPascalCase %>Function extends <% if (isJava) { %>SnapStart<% } %>Function { + public <%- operation.operationIdPascalCase %>Function(@NotNull Construct scope, @NotNull String id, @NotNull <%- operation.operationIdPascalCase %>FunctionProps props) { super(scope, id, props); } - public {{operationIdCamelCase}}Function(@NotNull Construct scope, @NotNull String id) { - this(scope, id, {{operationIdCamelCase}}FunctionProps.builder().build()); + public <%- operation.operationIdPascalCase %>Function(@NotNull Construct scope, @NotNull String id) { + this(scope, id, <%- operation.operationIdPascalCase %>FunctionProps.builder().build()); } } ###TSAPI_WRITE_FILE### { - "dir": "functions", - "name": "{{operationIdCamelCase}}FunctionProps", + "dir": "<%= metadata.srcDir || 'src' %>/functions", + "name": "<%- operation.operationIdPascalCase %>FunctionProps", "ext": ".java", "overwrite": true } -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}.functions; +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>.functions; import org.jetbrains.annotations.NotNull; import software.amazon.awscdk.Duration; @@ -79,12 +79,12 @@ import java.util.List; import java.util.Map; @lombok.Builder @lombok.Getter -public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vendorExtensions.x-handler.language 'java' ~}}SnapStart{{~/startsWith}}FunctionProps { +public class <%- operation.operationIdPascalCase %>FunctionProps implements <% if (isJava) { %>SnapStart<% } %>FunctionProps { private static String infraProjectAbsolutePath; static { try { - try (InputStream stream = {{operationIdCamelCase}}FunctionProps.class.getClassLoader() + try (InputStream stream = <%- operation.operationIdPascalCase %>FunctionProps.class.getClassLoader() .getResourceAsStream("project-absolute-path.txt")) { try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { infraProjectAbsolutePath = new BufferedReader(inputStreamReader).lines().findFirst() @@ -98,28 +98,28 @@ public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vend // Fixed props private final Code code = Code.fromAsset(Paths.get(infraProjectAbsolutePath).resolve( - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-typescript-asset-path}}{{/apis.0}}{{/apiInfo}}/###TSAPI_FN###{ "function": "kebabCase", "args": ["{{operationIdCamelCase}}"] }###/TSAPI_FN###" - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-asset-path}}{{/apis.0}}{{/apiInfo}}" - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-asset-path}}{{/apis.0}}{{/apiInfo}}" - {{~/startsWith}} + <%_ if (isTypeScript) { _%> + "<%- metadata['x-handlers-typescript-asset-path'] %>/<%- operation.operationIdKebabCase %>" + <%_ } else if (isPython) { _%> + "<%- metadata['x-handlers-python-asset-path'] %>" + <%_ } else if (isJava) { _%> + "<%- metadata['x-handlers-java-asset-path'] %>" + <%_ } _%> ).toAbsolutePath().toString()); - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} + <%_ if (isTypeScript) { _%> private final String handler = "index.handler"; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - private final String handler = "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-module}}{{/apis.0}}{{/apiInfo}}.{{operationIdSnakeCase}}.handler"; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - private final String handler = "{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-package}}{{/apis.0}}{{/apiInfo}}.{{operationIdCamelCase}}Handler"; - {{~/startsWith}} - {{#startsWith vendorExtensions.x-handler.language 'typescript' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-node-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'python' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-python-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}}{{#startsWith vendorExtensions.x-handler.language 'java' ~}} - private final Runtime runtime = Runtime.{{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-java-lambda-runtime-version}}{{/apis.0}}{{/apiInfo}}; - {{~/startsWith}} + <%_ } else if (isPython) { _%> + private final String handler = "<%- metadata['x-handlers-python-module'] %>.<%- operation.operationIdSnakeCase %>.handler"; + <%_ } else if (isJava) { _%> + private final String handler = "<%- metadata['x-handlers-java-package'] %>.<%- operation.operationIdPascalCase %>Handler"; + <%_ } _%> + <%_ if (isTypeScript) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-node-lambda-runtime-version'] %>; + <%_ } else if (isPython) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-python-lambda-runtime-version'] %>; + <%_ } else if (isJava) { _%> + private final Runtime runtime = Runtime.<%- metadata['x-handlers-java-lambda-runtime-version'] %>; + <%_ } _%> // Props with defaults @lombok.Builder.Default @@ -165,8 +165,5 @@ public class {{operationIdCamelCase}}FunctionProps implements {{#startsWith vend IDestination onSuccess; Number retryAttempts; } -{{/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file +<%_ } _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.ejs new file mode 100644 index 000000000..5a895c635 --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.ejs @@ -0,0 +1,108 @@ +###TSAPI_WRITE_FILE### +{ + "id": "mock-integrations", + "dir": "<%= metadata.srcDir || 'src' %>", + "name": "MockIntegrations", + "ext": ".java", + "overwrite": true +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.JSON; +import <%- metadata.runtimePackageName %>.api.operation_config.OperationConfig; +import <%- metadata.runtimePackageName %>.model.*; +import software.aws.pdk.type_safe_api.Integrations; +import software.aws.pdk.type_safe_api.MockIntegration; +import software.aws.pdk.type_safe_api.MockIntegrationResponse; +import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.file.Paths; +import java.util.stream.Collectors; + + +/** + * Type-safe mock integrations for API operations + */ +public class MockIntegrations { + static { + // Instantiate json instance so that any .toJson() methods can be used + new JSON(); + } + + /** + * Read a mock data file for the given operation + */ + private static String readMockDataFile(final String method, final String path, final int statusCode) { + try { + try (InputStream stream = MockIntegrations.class.getClassLoader() + .getResourceAsStream(Paths.get("mocks", method + path.replaceAll("/", "-") + String.format("-%d.json", statusCode)).toString())) { + try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { + return new BufferedReader(inputStreamReader).lines().collect(Collectors.joining(System.lineSeparator())); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + <%_ if (metadata.enableMockIntegrations) { _%> + <%_ allOperations.forEach((operation) => { _%> + <%_ operation.responses.forEach((response) => { _%> + /** + * Mock integration to return a <%- response.code %> response from the <%- operation.name %> operation + */ + public static MockIntegration <%- operation.name %><%- response.code %>(<% if (response.type !== 'void') { %>final <% if (response.isPrimitive) { %>String<% } else { %><%- response.javaType %><% } %> body<% } %>) { + return Integrations.mock(MockIntegrationResponse.builder() + .statusCode(<%- response.code %>) + <%_ if (response.type !== 'void') { _%> + <%_ if (response.isPrimitive) { _%> + .body(body) + <%_ } else { _%> + .body(body.toJson()) + <%_ } _%> + <%_ } _%> + .build()); + } + <%_ if (response.type !== 'void') { _%> + <%_ if (!response.isPrimitive) { _%> + + /** + * Mock integration to return a <%- response.code %> response from the <%- operation.name %> operation, with generated mock data + */ + public static MockIntegration <%- operation.name %><%- response.code %>() { + return Integrations.mock(MockIntegrationResponse.builder() + .statusCode(<%- response.code %>) + .body(MockIntegrations.readMockDataFile("<%- operation.method.toLowerCase() %>", "<%- operation.path %>", <%- response.code %>)) + .build()); + } + <%_ } _%> + <%_ } _%> + + <%_ }); _%> + <%_ }); _%> + + /** + * Mock all operations for which generated JSON data can be returned. + * The first available response is used for each operation. In most cases this is the successful 200 response. + * @return a builder which you can use to override integrations for operations before calling .build() + */ + public static OperationConfig.OperationConfigBuilder mockAll() { + return OperationConfig.builder() + <%_ allOperations.forEach((operation) => { _%> + <%_ const firstResponse = operation.results[0] || operation.responses[0]; _%> + <%_ if (firstResponse && !firstResponse.isPrimitive) { _%> + .<%- operation.name %>(TypeSafeApiIntegration.builder() + .integration(MockIntegrations.<%- operation.name %><%- firstResponse.code %>()) + .build()) + <%_ } _%> + <%_ }); _%> + ; + } + <%_ } else { _%> + // No mock integrations have been generated, since mock data generation is disabled. + <%_ } _%> +} diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.mustache b/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.mustache deleted file mode 100644 index fbc620af7..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-cdk-infrastructure/templates/mockIntegrations.mustache +++ /dev/null @@ -1,117 +0,0 @@ -package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-infrastructure-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.JSON; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.operation_config.OperationConfig; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.model.*; -import software.aws.pdk.type_safe_api.Integrations; -import software.aws.pdk.type_safe_api.MockIntegration; -import software.aws.pdk.type_safe_api.MockIntegrationResponse; -import software.aws.pdk.type_safe_api.TypeSafeApiIntegration; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.file.Paths; -import java.util.stream.Collectors; - - -/** - * Type-safe mock integrations for API operations - */ -public class MockIntegrations { - static { - // Instantiate json instance so that any .toJson() methods can be used - new JSON(); - } - - /** - * Read a mock data file for the given operation - */ - private static String readMockDataFile(final String method, final String path, final int statusCode) { - try { - try (InputStream stream = MockIntegrations.class.getClassLoader() - .getResourceAsStream(Paths.get("mocks", method + path.replaceAll("/", "-") + String.format("-%d.json", statusCode)).toString())) { - try (InputStreamReader inputStreamReader = new InputStreamReader(stream)) { - return new BufferedReader(inputStreamReader).lines().collect(Collectors.joining(System.lineSeparator())); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - {{#apiInfo}}{{#apis.0}}{{#vendorExtensions.x-enable-mock-integrations}} - {{#apiInfo}} - {{#apis}} - {{#operations}} - {{#operation}} - {{#responses}} - /** - * Mock integration to return a {{code}} response from the {{nickname}} operation - */ - public static MockIntegration {{nickname}}{{code}}({{#dataType}}final {{#isPrimitiveType}}String{{/isPrimitiveType}}{{^isPrimitiveType}}{{.}}{{/isPrimitiveType}} body{{/dataType}}) { - return Integrations.mock(MockIntegrationResponse.builder() - .statusCode({{code}}) - {{#dataType}} - {{#isPrimitiveType}} - .body(body) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - .body(body.toJson()) - {{/isPrimitiveType}} - {{/dataType}} - .build()); - } - {{#dataType}} - {{^isPrimitiveType}} - - /** - * Mock integration to return a {{code}} response from the {{nickname}} operation, with generated mock data - */ - public static MockIntegration {{nickname}}{{code}}() { - return Integrations.mock(MockIntegrationResponse.builder() - .statusCode({{code}}) - .body(MockIntegrations.readMockDataFile("{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}", "{{path}}", {{code}})) - .build()); - } - {{/isPrimitiveType}} - {{/dataType}} - - {{/responses}} - {{/operation}} - {{/operations}} - {{/apis}} - {{/apiInfo}} - - /** - * Mock all operations for which generated JSON data can be returned. - * The first available response is used for each operation. In most cases this is the successful 200 response. - * @return a builder which you can use to override integrations for operations before calling .build() - */ - public static OperationConfig.OperationConfigBuilder mockAll() { - return OperationConfig.builder() - {{#apiInfo}} - {{#apis}} - {{#operations}} - {{#operation}} - {{#responses.0}} - {{#dataType}} - {{^isPrimitiveType}} - .{{nickname}}(TypeSafeApiIntegration.builder() - .integration(MockIntegrations.{{nickname}}{{code}}()) - .build()) - {{/isPrimitiveType}} - {{/dataType}} - {{/responses.0}} - {{/operation}} - {{/operations}} - {{/apis}} - {{/apiInfo}} - ; - } - {{/vendorExtensions.x-enable-mock-integrations}}{{/apis.0}}{{/apiInfo}} - {{#apiInfo}}{{#apis.0}}{{^vendorExtensions.x-enable-mock-integrations}} - // No mock integrations have been generated, since mock data generation is disabled. - {{/vendorExtensions.x-enable-mock-integrations}}{{/apis.0}}{{/apiInfo}} -} diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/config.yaml b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/config.yaml deleted file mode 100644 index 2de3db934..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -files: - handlers.handlebars: - destinationFilename: {{src}}/__all_handlers.java - templateType: SupportingFiles - tests.handlebars: - destinationFilename: {{tst}}/__all_tests.java - templateType: SupportingFiles diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.ejs new file mode 100644 index 000000000..d2dfb0544 --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.ejs @@ -0,0 +1,81 @@ +<%_ services.forEach((service) => { _%> +<%_ service.operations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler'] && operation.vendorExtensions['x-handler'].language === 'java') { _%> +###TSAPI_WRITE_FILE### +{ + "id": "<%- operation.name %>", + "dir": "<%- metadata.srcDir || 'src' %>", + "name": "<%- operation.operationIdPascalCase %>Handler", + "ext": ".java", + "overwrite": false +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.api.interceptors.DefaultInterceptors; +import <%- metadata.runtimePackageName %>.api.handlers.Interceptor; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Input; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>500Response; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestInput; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Response; +import <%- metadata.runtimePackageName %>.model.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.List; + +/** + * Entry point for the AWS Lambda handler for the <%- operation.operationIdPascalCase %> operation. + * The <%- operation.operationIdPascalCase %> class manages marshalling inputs and outputs. + */ +public class <%- operation.operationIdPascalCase %>Handler extends <%- operation.operationIdPascalCase %> { + /** + * Interceptors are initialised once during the lambda "init" phase + */ + private final ListInput>> interceptors = DefaultInterceptors.all(); + + /** + * Use the logger to log requests. The LoggingInterceptor sets up all loggers to include lambda context values in your logs. + */ + private final Logger log = LogManager.getLogger(<%- operation.operationIdPascalCase %>Handler.class); + + /** + * Return the interceptors for this handler. + * You can also use the @Interceptors annotation on the class to add interceptors + */ + @Override + public ListInput>> getInterceptors() { + return this.interceptors; + } + + /** + * This method is executed prior to the Java SnapStart snapshot being taken. + * Perform any warmup activities to "prime" your function here. Code in this function will be just-in-time compiled, + * before the snapshot is taken, and thus optimised ready for the first invocation. + * For example if your function interacts with DynamoDB, perform a simple read operation here. + * @see https://aws.amazon.com/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ + */ + @Override + public void warmUp() { + + } + + /** + * Type-safe handler for the <%- operation.operationIdPascalCase %> operation + */ + @Override + public <%- operation.operationIdPascalCase %>Response handle(final <%- operation.operationIdPascalCase %>RequestInput request) { + log.info("Start <%- operation.operationIdPascalCase %> Operation"); + + // TODO: Implement <%- operation.operationIdPascalCase %> Operation. `input` contains the request input. + <%- operation.operationIdPascalCase %>Input input = request.getInput(); + + return <%- operation.operationIdPascalCase %>500Response.of(InternalFailureErrorResponseContent.builder() + .message("Not Implemented!") + .build()); + } +} + +<%_ } _%> +<%_ }); _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.handlebars deleted file mode 100644 index aa68c9ee1..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/handlers.handlebars +++ /dev/null @@ -1,88 +0,0 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} -{{#startsWith vendorExtensions.x-handler.language 'java'}} -###TSAPI_WRITE_FILE### -{ - "id": "{{operationIdCamelCase}}Handler", - "dir": ".", - "name": "{{operationIdCamelCase}}Handler", - "ext": ".java", - "overwrite": false -} -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.interceptors.DefaultInterceptors; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.Interceptor; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Input; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}500Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestInput; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.model.*; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.List; - -/** - * Entry point for the AWS Lambda handler for the {{operationIdCamelCase}} operation. - * The {{operationIdCamelCase}} class manages marshalling inputs and outputs. - */ -public class {{operationIdCamelCase}}Handler extends {{operationIdCamelCase}} { - /** - * Interceptors are initialised once during the lambda "init" phase - */ - private final List> interceptors = DefaultInterceptors.all(); - - /** - * Use the logger to log requests. The LoggingInterceptor sets up all loggers to include lambda context values in your logs. - */ - private final Logger log = LogManager.getLogger({{operationIdCamelCase}}Handler.class); - - /** - * Return the interceptors for this handler. - * You can also use the @Interceptors annotation on the class to add interceptors - */ - @Override - public List> getInterceptors() { - return this.interceptors; - } - - /** - * This method is executed prior to the Java SnapStart snapshot being taken. - * Perform any warmup activities to "prime" your function here. Code in this function will be just-in-time compiled, - * before the snapshot is taken, and thus optimised ready for the first invocation. - * For example if your function interacts with DynamoDB, perform a simple read operation here. - * @see https://aws.amazon.com/blogs/compute/reducing-java-cold-starts-on-aws-lambda-functions-with-snapstart/ - */ - @Override - public void warmUp() { - - } - - /** - * Type-safe handler for the {{operationIdCamelCase}} operation - */ - @Override - public {{operationIdCamelCase}}Response handle(final {{operationIdCamelCase}}RequestInput request) { - log.info("Start {{operationIdCamelCase}} Operation"); - - // TODO: Implement {{operationIdCamelCase}} Operation. `input` contains the request input. - {{operationIdCamelCase}}Input input = request.getInput(); - - return {{operationIdCamelCase}}500Response.of(InternalFailureErrorResponseContent.builder() - .message("Not Implemented!") - .build()); - } -} - -{{~/startsWith}} -{{~/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.ejs b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.ejs new file mode 100644 index 000000000..a777c620a --- /dev/null +++ b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.ejs @@ -0,0 +1,50 @@ +<%_ services.forEach((service) => { _%> +<%_ service.operations.forEach((operation) => { _%> +<%_ if (operation.vendorExtensions && operation.vendorExtensions['x-handler'] && operation.vendorExtensions['x-handler'].language === 'java') { _%> +###TSAPI_WRITE_FILE### +{ + "id": "<%- operation.name %>Test", + "dir": "<%- metadata.tstDir || 'tst' %>", + "name": "<%- operation.operationIdPascalCase %>HandlerTest", + "ext": ".java", + "generateConditionallyId": "<%- operation.name %>" +} +###/TSAPI_WRITE_FILE###package <%- metadata.packageName %>; + +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Input; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>500Response; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestInput; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>RequestParameters; +import <%- metadata.runtimePackageName %>.api.handlers.<%- operation.operationIdSnakeCase %>.<%- operation.operationIdPascalCase %>Response; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for <%- operation.operationIdPascalCase %>Handler + */ +public class <%- operation.operationIdPascalCase %>HandlerTest { + @Test + public void shouldReturnNotImplementedError() { + // TODO: Update the test as appropriate when you implement your handler + <%- operation.operationIdPascalCase %>Response response = new <%- operation.operationIdPascalCase %>Handler().handle(<%- operation.operationIdPascalCase %>RequestInput.builder() + .interceptorContext(new HashMap<>()) + .input(<%- operation.operationIdPascalCase %>Input.builder() + .requestParameters(<%- operation.operationIdPascalCase %>RequestParameters.builder() + // Add request parameters here... + .build()) + // If the request has a body you can add it here... + .build()) + .build()); + assertEquals(500, response.getStatusCode()); + + // Cast to the particular type of response returned to access the typed response body + assertEquals("Not Implemented!", ((<%- operation.operationIdPascalCase %>500Response) response).getTypedBody().getMessage()); + } +} + +<%_ } _%> +<%_ }); _%> +<%_ }); _%> \ No newline at end of file diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.handlebars b/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.handlebars deleted file mode 100644 index 13e6751ed..000000000 --- a/packages/type-safe-api/scripts/type-safe-api/generators/java-lambda-handlers/templates/tests.handlebars +++ /dev/null @@ -1,57 +0,0 @@ -###TSAPI_SPLIT_FILE### -{{#apiInfo ~}} -{{#apis ~}} -{{#operations ~}} -{{#operation ~}} -{{#if vendorExtensions.x-handler}} -{{#startsWith vendorExtensions.x-handler.language 'java'}} -###TSAPI_WRITE_FILE### -{ - "id": "{{operationIdCamelCase}}HandlerTest", - "dir": ".", - "name": "{{operationIdCamelCase}}HandlerTest", - "ext": ".java", - "generateConditionallyId": "{{operationIdCamelCase}}Handler" -} -###/TSAPI_WRITE_FILE###package {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-handlers-package}}{{/apis.0}}{{/apiInfo}}; - -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Input; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}500Response; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestInput; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}RequestParameters; -import {{#apiInfo}}{{#apis.0}}{{vendorExtensions.x-runtime-package}}{{/apis.0}}{{/apiInfo}}.api.handlers.{{operationIdSnakeCase}}.{{operationIdCamelCase}}Response; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Tests for {{operationIdCamelCase}}Handler - */ -public class {{operationIdCamelCase}}HandlerTest { - @Test - public void shouldReturnNotImplementedError() { - // TODO: Update the test as appropriate when you implement your handler - {{operationIdCamelCase}}Response response = new {{operationIdCamelCase}}Handler().handle({{operationIdCamelCase}}RequestInput.builder() - .interceptorContext(new HashMap<>()) - .input({{operationIdCamelCase}}Input.builder() - .requestParameters({{operationIdCamelCase}}RequestParameters.builder() - // Add request parameters here... - .build()) - // If the request has a body you can add it here... - .build()) - .build()); - assertEquals(500, response.getStatusCode()); - - // Cast to the particular type of response returned to access the typed response body - assertEquals("Not Implemented!", (({{operationIdCamelCase}}500Response) response).getTypedBody().getMessage()); - } -} - -{{~/startsWith}} -{{~/if}} -{{~/operation}} -{{~/operations}} -{{~/apis}} -{{~/apiInfo}} \ No newline at end of file diff --git a/packages/type-safe-api/src/project/codegen/handlers/generated-java-async-handlers-project.ts b/packages/type-safe-api/src/project/codegen/handlers/generated-java-async-handlers-project.ts index e1415fdb6..c7eb2c02d 100644 --- a/packages/type-safe-api/src/project/codegen/handlers/generated-java-async-handlers-project.ts +++ b/packages/type-safe-api/src/project/codegen/handlers/generated-java-async-handlers-project.ts @@ -4,7 +4,7 @@ import { GeneratedJavaHandlersBaseProject, GeneratedJavaHandlersBaseProjectOptions, } from "./generated-java-handlers-base-project"; -import { GenerationOptions, OtherGenerators } from "../components/utils"; +import { CodegenOptions, OtherGenerators } from "../components/utils"; export interface GeneratedJavaAsyncHandlersProjectOptions extends GeneratedJavaHandlersBaseProjectOptions {} @@ -14,22 +14,16 @@ export class GeneratedJavaAsyncHandlersProject extends GeneratedJavaHandlersBase super(options); } - public buildOpenApiGeneratorOptions(): GenerationOptions { + public buildCodegenOptions(): CodegenOptions { return { - generator: "java", specPath: this.options.specPath, - generatorDirectory: OtherGenerators.JAVA_ASYNC_LAMBDA_HANDLERS, - srcDir: this.srcDir, - tstDir: this.tstDir, - normalizers: { - KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, + templateDirs: [OtherGenerators.JAVA_ASYNC_LAMBDA_HANDLERS], + metadata: { + srcDir: this.srcDir, + tstDir: this.tstDir, + packageName: this.packageName, + runtimePackageName: this.options.generatedJavaTypes.packageName, }, - extraVendorExtensions: { - "x-handlers-package": this.packageName, - "x-runtime-package": this.options.generatedJavaTypes.packageName, - }, - // Do not generate map/list types. Generator will use built in HashMap, ArrayList instead - generateAliasAsModel: false, }; } } diff --git a/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-base-project.ts b/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-base-project.ts index 9d0011a83..715f2d5f1 100644 --- a/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-base-project.ts +++ b/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-base-project.ts @@ -8,15 +8,11 @@ import { CodeGenerationSourceOptions, GeneratedJavaHandlersOptions, } from "../../types"; -import { OpenApiGeneratorHandlebarsIgnoreFile } from "../components/open-api-generator-handlebars-ignore-file"; -import { OpenApiGeneratorIgnoreFile } from "../components/open-api-generator-ignore-file"; -import { OpenApiToolsJsonFile } from "../components/open-api-tools-json-file"; import { TypeSafeApiCommandEnvironment } from "../components/type-safe-api-command-environment"; import { - buildCleanOpenApiGeneratedCodeCommand, - buildInvokeOpenApiGeneratorCommandArgs, + buildCodegenCommandArgs, buildTypeSafeApiExecCommand, - GenerationOptions, + CodegenOptions, TypeSafeApiScript, } from "../components/utils"; import { GeneratedJavaRuntimeBaseProject } from "../runtime/generated-java-runtime-base-project"; @@ -117,31 +113,10 @@ export abstract class GeneratedJavaHandlersBaseProject extends JavaProject { id: `${options.generatedJavaTypes.pom.groupId}-${options.generatedJavaTypes.pom.artifactId}-repo`, }); - // Ignore everything for the first mustache pass - const openapiGeneratorIgnore = new OpenApiGeneratorIgnoreFile(this); - openapiGeneratorIgnore.addPatterns("/*", "**/*", "*"); - // Ignore everything but the handler files for the handlebars pass - const openapiGeneratorHandlebarsIgnore = - new OpenApiGeneratorHandlebarsIgnoreFile(this); - openapiGeneratorHandlebarsIgnore.addPatterns( - "/*", - "**/*", - "*", - // This will be split into a file per targeted handler - `!${this.srcDir}/__all_handlers.java`, - `!${this.tstDir}/__all_tests.java` - ); - - // Add OpenAPI Generator cli configuration - OpenApiToolsJsonFile.ensure(this).addOpenApiGeneratorCliConfig( - options.openApiGeneratorCliConfig - ); - const generateTask = this.addTask("generate"); - generateTask.exec(buildCleanOpenApiGeneratedCodeCommand()); generateTask.exec( buildTypeSafeApiExecCommand( - TypeSafeApiScript.GENERATE, + TypeSafeApiScript.GENERATE_NEXT, this.buildGenerateCommandArgs() ) ); @@ -149,7 +124,7 @@ export abstract class GeneratedJavaHandlersBaseProject extends JavaProject { this.preCompileTask.spawn(generateTask); // Ignore the openapi generator metadata files - this.gitignore.addPatterns(".openapi-generator"); + this.gitignore.addPatterns(".openapi-generator", ".tsapi-manifest"); // Use the maven shade plugin to build a "super jar" which we can deploy to AWS Lambda this.pom.addPlugin("org.apache.maven.plugins/maven-shade-plugin@3.3.0", { @@ -205,10 +180,8 @@ export abstract class GeneratedJavaHandlersBaseProject extends JavaProject { } public buildGenerateCommandArgs = () => { - return buildInvokeOpenApiGeneratorCommandArgs( - this.buildOpenApiGeneratorOptions() - ); + return buildCodegenCommandArgs(this.buildCodegenOptions()); }; - public abstract buildOpenApiGeneratorOptions(): GenerationOptions; + public abstract buildCodegenOptions(): CodegenOptions; } diff --git a/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-project.ts b/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-project.ts index ca42921eb..76eb7b1b7 100644 --- a/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-project.ts +++ b/packages/type-safe-api/src/project/codegen/handlers/generated-java-handlers-project.ts @@ -4,7 +4,7 @@ import { GeneratedJavaHandlersBaseProject, GeneratedJavaHandlersBaseProjectOptions, } from "./generated-java-handlers-base-project"; -import { GenerationOptions, OtherGenerators } from "../components/utils"; +import { CodegenOptions, OtherGenerators } from "../components/utils"; export interface GeneratedJavaHandlersProjectOptions extends GeneratedJavaHandlersBaseProjectOptions {} @@ -14,22 +14,16 @@ export class GeneratedJavaHandlersProject extends GeneratedJavaHandlersBaseProje super(options); } - public buildOpenApiGeneratorOptions(): GenerationOptions { + public buildCodegenOptions(): CodegenOptions { return { - generator: "java", specPath: this.options.specPath, - generatorDirectory: OtherGenerators.JAVA_LAMBDA_HANDLERS, - srcDir: this.srcDir, - tstDir: this.tstDir, - normalizers: { - KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, + templateDirs: [OtherGenerators.JAVA_LAMBDA_HANDLERS], + metadata: { + srcDir: this.srcDir, + tstDir: this.tstDir, + packageName: this.packageName, + runtimePackageName: this.options.generatedJavaTypes.packageName, }, - extraVendorExtensions: { - "x-handlers-package": this.packageName, - "x-runtime-package": this.options.generatedJavaTypes.packageName, - }, - // Do not generate map/list types. Generator will use built in HashMap, ArrayList instead - generateAliasAsModel: false, }; } } diff --git a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-async-cdk-infrastructure-project.ts b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-async-cdk-infrastructure-project.ts index 4afc071b0..d3127f750 100644 --- a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-async-cdk-infrastructure-project.ts +++ b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-async-cdk-infrastructure-project.ts @@ -5,7 +5,7 @@ import { GeneratedJavaCdkInfrastructureBaseProjectOptions, } from "./generated-java-cdk-infrastructure-base-project"; import { - GenerationOptions, + CodegenOptions, OtherGenerators, getHandlersProjectVendorExtensions, } from "../../components/utils"; @@ -18,25 +18,19 @@ export class GeneratedJavaAsyncCdkInfrastructureProject extends GeneratedJavaCdk super(options); } - public buildOpenApiGeneratorOptions(): GenerationOptions { + public buildCodegenOptions(): CodegenOptions { return { - generator: "java", specPath: this.options.specPath, - generatorDirectory: OtherGenerators.JAVA_ASYNC_CDK_INFRASTRUCTURE, - srcDir: this.srcDir, - normalizers: { - KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, - }, - extraVendorExtensions: { - "x-infrastructure-package": this.packageName, - "x-runtime-package": this.options.generatedJavaTypes.packageName, + templateDirs: [OtherGenerators.JAVA_ASYNC_CDK_INFRASTRUCTURE], + metadata: { + srcDir: this.srcDir, + packageName: this.packageName, + runtimePackageName: this.options.generatedJavaTypes.packageName, ...getHandlersProjectVendorExtensions( this, this.options.generatedHandlers ), }, - // Do not generate map/list types. Generator will use built in HashMap, ArrayList instead - generateAliasAsModel: false, }; } } diff --git a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-base-project.ts b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-base-project.ts index 345bf246e..b23e3d133 100644 --- a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-base-project.ts +++ b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-base-project.ts @@ -8,15 +8,11 @@ import { CodeGenerationSourceOptions, GeneratedWithOpenApiGeneratorOptions, } from "../../../types"; -import { OpenApiGeneratorHandlebarsIgnoreFile } from "../../components/open-api-generator-handlebars-ignore-file"; -import { OpenApiGeneratorIgnoreFile } from "../../components/open-api-generator-ignore-file"; -import { OpenApiToolsJsonFile } from "../../components/open-api-tools-json-file"; import { TypeSafeApiCommandEnvironment } from "../../components/type-safe-api-command-environment"; import { - buildCleanOpenApiGeneratedCodeCommand, - buildInvokeOpenApiGeneratorCommandArgs, + buildCodegenCommandArgs, buildTypeSafeApiExecCommand, - GenerationOptions, + CodegenOptions, TypeSafeApiScript, } from "../../components/utils"; import { GeneratedHandlersProjects } from "../../generate"; @@ -59,7 +55,6 @@ export abstract class GeneratedJavaCdkInfrastructureBaseProject extends JavaProj * Code generation task */ protected readonly generateTask: Task; - protected readonly openapiGeneratorIgnore: OpenApiGeneratorIgnoreFile; constructor(options: GeneratedJavaCdkInfrastructureBaseProjectOptions) { super({ @@ -113,37 +108,11 @@ export abstract class GeneratedJavaCdkInfrastructureBaseProject extends JavaProj id: `${options.generatedJavaTypes.pom.groupId}-${options.generatedJavaTypes.pom.artifactId}-repo`, }); - // Ignore everything but the target files - const openapiGeneratorIgnore = new OpenApiGeneratorIgnoreFile(this); - this.openapiGeneratorIgnore = openapiGeneratorIgnore; - openapiGeneratorIgnore.addPatterns( - "/*", - "**/*", - "*", - `!${this.srcDir}/Api.java`, - `!${this.srcDir}/ApiProps.java` - ); - - const openapiGeneratorHandlebarsIgnore = - new OpenApiGeneratorHandlebarsIgnoreFile(this); - openapiGeneratorHandlebarsIgnore.addPatterns( - "/*", - "**/*", - "*", - `!${this.srcDir}/__functions.java` - ); - - // Add OpenAPI Generator cli configuration - OpenApiToolsJsonFile.ensure(this).addOpenApiGeneratorCliConfig( - options.openApiGeneratorCliConfig - ); - const generateTask = this.addTask("generate"); this.generateTask = generateTask; - generateTask.exec(buildCleanOpenApiGeneratedCodeCommand()); generateTask.exec( buildTypeSafeApiExecCommand( - TypeSafeApiScript.GENERATE, + TypeSafeApiScript.GENERATE_NEXT, this.buildGenerateCommandArgs() ) ); @@ -163,10 +132,8 @@ export abstract class GeneratedJavaCdkInfrastructureBaseProject extends JavaProj } public buildGenerateCommandArgs = () => { - return buildInvokeOpenApiGeneratorCommandArgs( - this.buildOpenApiGeneratorOptions() - ); + return buildCodegenCommandArgs(this.buildCodegenOptions()); }; - protected abstract buildOpenApiGeneratorOptions(): GenerationOptions; + protected abstract buildCodegenOptions(): CodegenOptions; } diff --git a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-project.ts b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-project.ts index b2462a40d..8d97580d7 100644 --- a/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-project.ts +++ b/packages/type-safe-api/src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-project.ts @@ -7,7 +7,7 @@ import { import { MockResponseGenerationOptions } from "../../../types"; import { buildInvokeMockDataGeneratorCommand, - GenerationOptions, + CodegenOptions, getHandlersProjectVendorExtensions, OtherGenerators, } from "../../components/utils"; @@ -26,33 +26,22 @@ export class GeneratedJavaCdkInfrastructureProject extends GeneratedJavaCdkInfra if (!this.options.mockDataOptions?.disable) { this.generateTask.exec(this.buildGenerateMockDataCommand()); } - - this.openapiGeneratorIgnore.addPatterns( - `!${this.srcDir}/MockIntegrations.java` - ); } - public buildOpenApiGeneratorOptions(): GenerationOptions { + public buildCodegenOptions(): CodegenOptions { return { - generator: "java", specPath: this.options.specPath, - generatorDirectory: OtherGenerators.JAVA_CDK_INFRASTRUCTURE, - srcDir: this.srcDir, - normalizers: { - KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, - }, - extraVendorExtensions: { - "x-infrastructure-package": this.packageName, - "x-runtime-package": this.options.generatedJavaTypes.packageName, - // Enable mock integration generation by default - "x-enable-mock-integrations": !this.options.mockDataOptions?.disable, + templateDirs: [OtherGenerators.JAVA_CDK_INFRASTRUCTURE], + metadata: { + srcDir: this.srcDir, + packageName: this.packageName, + runtimePackageName: this.options.generatedJavaTypes.packageName, + enableMockIntegrations: !this.options.mockDataOptions?.disable, ...getHandlersProjectVendorExtensions( this, this.options.generatedHandlers ), }, - // Do not generate map/list types. Generator will use built in HashMap, ArrayList instead - generateAliasAsModel: false, }; } diff --git a/packages/type-safe-api/test/project/__snapshots__/type-safe-api-project.test.ts.snap b/packages/type-safe-api/test/project/__snapshots__/type-safe-api-project.test.ts.snap index 5d82ef7b0..5eff4b8a3 100644 --- a/packages/type-safe-api/test/project/__snapshots__/type-safe-api-project.test.ts.snap +++ b/packages/type-safe-api/test/project/__snapshots__/type-safe-api-project.test.ts.snap @@ -1,20 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Type Safe Api Project Unit Tests Custom OpenAPI Generator CLI Configuration 1`] = ` -{ - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "repository": { - "downloadUrl": "https://my.custom.maven.repo/maven2/\${groupId}/\${artifactId}/\${versionName}/\${artifactId}-\${versionName}.jar", - }, - "storageDir": "~/.my-storage-dir", - "useDocker": true, - "version": "6.2.0", - }, - "spaces": 2, -} -`; +exports[`Type Safe Api Project Unit Tests Custom OpenAPI Generator CLI Configuration 1`] = `undefined`; exports[`Type Safe Api Project Unit Tests Custom OpenAPI Generator CLI Configuration 2`] = ` { @@ -649,9 +635,6 @@ This directory contains a generated type-safe CDK construct which can provision /.gitattributes linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -670,36 +653,8 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/project.json ", - "generated/infrastructure/java/.openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/com/generated/api/openapijavajavainfra/infra/Api.java -!src/main/java/com/generated/api/openapijavajavainfra/infra/ApiProps.java -!src/main/java/com/generated/api/openapijavajavainfra/infra/MockIntegrations.java -", - "generated/infrastructure/java/.openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -/* -**/* -* -!src/main/java/com/generated/api/openapijavajavainfra/infra/__functions.java -", - "generated/infrastructure/java/.pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, "generated/infrastructure/java/.projen/deps.json": { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", "dependencies": [ @@ -844,9 +799,6 @@ dist/java "files": [ ".gitattributes", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -890,14 +842,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -912,13 +856,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path ../../../model/.api.json --output-path . --generator-dir java-cdk-infrastructure --src-dir src/main/java/com/generated/api/openapijavajavainfra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"com.generated.api.openapijavajavainfra.infra","x-runtime-package":"com.generated.api.openapijavajavaruntime.runtime","x-enable-mock-integrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "java-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/com/generated/api/openapijavajavainfra/infra","packageName":"com.generated.api.openapijavajavainfra.infra","runtimePackageName":"com.generated.api.openapijavajavaruntime.runtime","enableMockIntegrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", @@ -1135,13 +1073,6 @@ dist/java "cwd": "generated/infrastructure/java", }, }, - "create-openapitools.json": { - "executor": "nx:run-commands", - "options": { - "command": "npx projen create-openapitools.json", - "cwd": "generated/infrastructure/java", - }, - }, "default": { "executor": "nx:run-commands", "options": { @@ -5842,9 +5773,6 @@ This directory contains a generated type-safe CDK construct which can provision /.gitattributes linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -5864,37 +5792,9 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/project.json !/LICENSE ", - "packages/api/generated/infrastructure/java/.openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/com/generated/api/openapijavajavainfra/infra/Api.java -!src/main/java/com/generated/api/openapijavajavainfra/infra/ApiProps.java -!src/main/java/com/generated/api/openapijavajavainfra/infra/MockIntegrations.java -", - "packages/api/generated/infrastructure/java/.openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -/* -**/* -* -!src/main/java/com/generated/api/openapijavajavainfra/infra/__functions.java -", - "packages/api/generated/infrastructure/java/.pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, "packages/api/generated/infrastructure/java/.projen/deps.json": { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", "dependencies": [ @@ -6039,9 +5939,6 @@ dist/java "files": [ ".gitattributes", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -6086,14 +5983,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -6102,13 +5991,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path ../../../model/.api.json --output-path . --generator-dir java-cdk-infrastructure --src-dir src/main/java/com/generated/api/openapijavajavainfra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"com.generated.api.openapijavajavainfra.infra","x-runtime-package":"com.generated.api.openapijavajavaruntime.runtime","x-enable-mock-integrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "java-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/com/generated/api/openapijavajavainfra/infra","packageName":"com.generated.api.openapijavajavainfra.infra","runtimePackageName":"com.generated.api.openapijavajavaruntime.runtime","enableMockIntegrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", @@ -6536,13 +6419,6 @@ dist/java "cwd": "packages/api/generated/infrastructure/java", }, }, - "create-openapitools.json": { - "executor": "nx:run-commands", - "options": { - "command": "npx projen create-openapitools.json", - "cwd": "packages/api/generated/infrastructure/java", - }, - }, "default": { "executor": "nx:run-commands", "options": { @@ -30546,9 +30422,6 @@ Whenever an operation is annotated with the \`@handler\` trait in Smithy (or the /.gitattributes linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -30567,35 +30440,10 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json .openapi-generator +.tsapi-manifest !/project.json ", - "handlers/java/.openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -.gitignore -/* -**/* -* -", - "handlers/java/.openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -/* -**/* -* -!src/main/java/com/generated/api/smithyhandlersjavahandlers/handlers/__all_handlers.java -!src/test/java/com/generated/api/smithyhandlersjavahandlers/handlers/__all_tests.java -", - "handlers/java/.pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, "handlers/java/.projen/deps.json": { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", "dependencies": [ @@ -30754,9 +30602,6 @@ dist/java "files": [ ".gitattributes", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -30800,14 +30645,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -30822,13 +30659,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path ../../model/.api.json --output-path . --generator-dir java-lambda-handlers --src-dir src/main/java/com/generated/api/smithyhandlersjavahandlers/handlers --tst-dir src/test/java/com/generated/api/smithyhandlersjavahandlers/handlers --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-handlers-package":"com.generated.api.smithyhandlersjavahandlers.handlers","x-runtime-package":"com.generated.api.smithyhandlersjavaruntime.runtime"}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../model/.api.json --outputPath . --templateDirs "java-lambda-handlers" --metadata '{"srcDir":"src/main/java/com/generated/api/smithyhandlersjavahandlers/handlers","tstDir":"src/test/java/com/generated/api/smithyhandlersjavahandlers/handlers","packageName":"com.generated.api.smithyhandlersjavahandlers.handlers","runtimePackageName":"com.generated.api.smithyhandlersjavaruntime.runtime"}'", }, ], }, @@ -31045,13 +30876,6 @@ dist/java "cwd": "handlers/java", }, }, - "create-openapitools.json": { - "executor": "nx:run-commands", - "options": { - "command": "npx projen create-openapitools.json", - "cwd": "handlers/java", - }, - }, "default": { "executor": "nx:run-commands", "options": { @@ -35915,9 +35739,6 @@ This directory contains a generated type-safe CDK construct which can provision /.gitattributes linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -35936,36 +35757,8 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/project.json ", - "generated/infrastructure/java/.openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/com/generated/api/smithyjavajavainfra/infra/Api.java -!src/main/java/com/generated/api/smithyjavajavainfra/infra/ApiProps.java -!src/main/java/com/generated/api/smithyjavajavainfra/infra/MockIntegrations.java -", - "generated/infrastructure/java/.openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -/* -**/* -* -!src/main/java/com/generated/api/smithyjavajavainfra/infra/__functions.java -", - "generated/infrastructure/java/.pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, "generated/infrastructure/java/.projen/deps.json": { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", "dependencies": [ @@ -36110,9 +35903,6 @@ dist/java "files": [ ".gitattributes", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -36156,14 +35946,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -36178,13 +35960,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path ../../../model/.api.json --output-path . --generator-dir java-cdk-infrastructure --src-dir src/main/java/com/generated/api/smithyjavajavainfra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"com.generated.api.smithyjavajavainfra.infra","x-runtime-package":"com.generated.api.smithyjavajavaruntime.runtime","x-enable-mock-integrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "java-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/com/generated/api/smithyjavajavainfra/infra","packageName":"com.generated.api.smithyjavajavainfra.infra","runtimePackageName":"com.generated.api.smithyjavajavaruntime.runtime","enableMockIntegrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", @@ -36401,13 +36177,6 @@ dist/java "cwd": "generated/infrastructure/java", }, }, - "create-openapitools.json": { - "executor": "nx:run-commands", - "options": { - "command": "npx projen create-openapitools.json", - "cwd": "generated/infrastructure/java", - }, - }, "default": { "executor": "nx:run-commands", "options": { @@ -41202,9 +40971,6 @@ This directory contains a generated type-safe CDK construct which can provision /.gitattributes linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -41224,37 +40990,9 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/project.json !/LICENSE ", - "packages/api/generated/infrastructure/java/.openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/com/generated/api/smithyjavajavainfra/infra/Api.java -!src/main/java/com/generated/api/smithyjavajavainfra/infra/ApiProps.java -!src/main/java/com/generated/api/smithyjavajavainfra/infra/MockIntegrations.java -", - "packages/api/generated/infrastructure/java/.openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". -/* -**/* -* -!src/main/java/com/generated/api/smithyjavajavainfra/infra/__functions.java -", - "packages/api/generated/infrastructure/java/.pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, "packages/api/generated/infrastructure/java/.projen/deps.json": { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".", "dependencies": [ @@ -41399,9 +41137,6 @@ dist/java "files": [ ".gitattributes", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -41446,14 +41181,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -41462,13 +41189,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path ../../../model/.api.json --output-path . --generator-dir java-cdk-infrastructure --src-dir src/main/java/com/generated/api/smithyjavajavainfra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"com.generated.api.smithyjavajavainfra.infra","x-runtime-package":"com.generated.api.smithyjavajavaruntime.runtime","x-enable-mock-integrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath ../../../model/.api.json --outputPath . --templateDirs "java-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/com/generated/api/smithyjavajavainfra/infra","packageName":"com.generated.api.smithyjavajavainfra.infra","runtimePackageName":"com.generated.api.smithyjavajavaruntime.runtime","enableMockIntegrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", @@ -41896,13 +41617,6 @@ dist/java "cwd": "packages/api/generated/infrastructure/java", }, }, - "create-openapitools.json": { - "executor": "nx:run-commands", - "options": { - "command": "npx projen create-openapitools.json", - "cwd": "packages/api/generated/infrastructure/java", - }, - }, "default": { "executor": "nx:run-commands", "options": { diff --git a/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-async-handlers-project.test.ts.snap b/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-async-handlers-project.test.ts.snap index d4355777f..41759c5c8 100644 --- a/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-async-handlers-project.test.ts.snap +++ b/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-async-handlers-project.test.ts.snap @@ -7,9 +7,6 @@ exports[`Generated Java Async Handlers Code Unit Tests Synth 1`] = ` /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -57,35 +54,10 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json .openapi-generator +.tsapi-manifest !/src/test/java/projenrc.java ", - ".openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -.gitignore -/* -**/* -* -", - ".openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -/* -**/* -* -!src/main/java/test/test-java-handlers/handlers/__all_handlers.java -!src/test/java/test/test-java-handlers/handlers/__all_tests.java -", - ".pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ @@ -250,9 +222,6 @@ dist/java ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -330,14 +299,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -366,13 +327,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path my-spec.json --output-path . --generator-dir java-async-lambda-handlers --src-dir src/main/java/test/test-java-handlers/handlers --tst-dir src/test/java/test/test-java-handlers/handlers --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-handlers-package":"test.test-java-handlers.handlers","x-runtime-package":"test.test-java-client.runtime"}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath my-spec.json --outputPath . --templateDirs "java-async-lambda-handlers" --metadata '{"srcDir":"src/main/java/test/test-java-handlers/handlers","tstDir":"src/test/java/test/test-java-handlers/handlers","packageName":"test.test-java-handlers.handlers","runtimePackageName":"test.test-java-client.runtime"}'", }, ], }, diff --git a/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-handlers-project.test.ts.snap b/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-handlers-project.test.ts.snap index d18d49b18..3b6c138e6 100644 --- a/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-handlers-project.test.ts.snap +++ b/packages/type-safe-api/test/project/codegen/handlers/__snapshots__/generated-java-handlers-project.test.ts.snap @@ -7,9 +7,6 @@ exports[`Generated Java Handlers Code Unit Tests Synth 1`] = ` /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -57,35 +54,10 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json .openapi-generator +.tsapi-manifest !/src/test/java/projenrc.java ", - ".openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -.gitignore -/* -**/* -* -", - ".openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -/* -**/* -* -!src/main/java/test/test-java-handlers/handlers/__all_handlers.java -!src/test/java/test/test-java-handlers/handlers/__all_tests.java -", - ".pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ @@ -250,9 +222,6 @@ dist/java ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -330,14 +299,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -366,13 +327,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path my-spec.json --output-path . --generator-dir java-lambda-handlers --src-dir src/main/java/test/test-java-handlers/handlers --tst-dir src/test/java/test/test-java-handlers/handlers --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-handlers-package":"test.test-java-handlers.handlers","x-runtime-package":"test.test-java-client.runtime"}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath my-spec.json --outputPath . --templateDirs "java-lambda-handlers" --metadata '{"srcDir":"src/main/java/test/test-java-handlers/handlers","tstDir":"src/test/java/test/test-java-handlers/handlers","packageName":"test.test-java-handlers.handlers","runtimePackageName":"test.test-java-client.runtime"}'", }, ], }, diff --git a/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-async-cdk-infrastructure-project.test.ts.snap b/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-async-cdk-infrastructure-project.test.ts.snap index e9808b59c..7f216d5fe 100644 --- a/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-async-cdk-infrastructure-project.test.ts.snap +++ b/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-async-cdk-infrastructure-project.test.ts.snap @@ -7,9 +7,6 @@ exports[`Generated Java Async Infra Code Unit Tests Synth 1`] = ` /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -57,35 +54,8 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/src/test/java/projenrc.java ", - ".openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/test/test-java-infra/infra/Api.java -!src/main/java/test/test-java-infra/infra/ApiProps.java -", - ".openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -/* -**/* -* -!src/main/java/test/test-java-infra/infra/__functions.java -", - ".pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ @@ -236,9 +206,6 @@ dist/java ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -316,14 +283,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -352,13 +311,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path my-spec.json --output-path . --generator-dir java-async-cdk-infrastructure --src-dir src/main/java/test/test-java-infra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"test.test-java-infra.infra","x-runtime-package":"test.test-java-client.runtime","x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath my-spec.json --outputPath . --templateDirs "java-async-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/test/test-java-infra/infra","packageName":"test.test-java-infra.infra","runtimePackageName":"test.test-java-client.runtime","x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", diff --git a/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-cdk-infrastructure-project.test.ts.snap b/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-cdk-infrastructure-project.test.ts.snap index ef074571d..f556ad6ef 100644 --- a/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-cdk-infrastructure-project.test.ts.snap +++ b/packages/type-safe-api/test/project/codegen/infrastructure/cdk/__snapshots__/generated-java-cdk-infrastructure-project.test.ts.snap @@ -7,9 +7,6 @@ exports[`Generated Java Infra Code Unit Tests Synth 1`] = ` /.gitattributes linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.gitignore linguist-generated -/.openapi-generator-ignore linguist-generated -/.openapi-generator-ignore-handlebars linguist-generated -/.pdk/dynamic-files/openapitools.json linguist-generated /.projen/** linguist-generated /.projen/deps.json linguist-generated /.projen/files.json linguist-generated @@ -57,36 +54,8 @@ node_modules/ .settings target dist/java -!/.openapi-generator-ignore -!/.openapi-generator-ignore-handlebars -!/.pdk/dynamic-files/openapitools.json -/openapitools.json !/src/test/java/projenrc.java ", - ".openapi-generator-ignore": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -.gitignore -/* -**/* -* -!src/main/java/test/test-java-infra/infra/Api.java -!src/main/java/test/test-java-infra/infra/ApiProps.java -!src/main/java/test/test-java-infra/infra/MockIntegrations.java -", - ".openapi-generator-ignore-handlebars": "# ~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen". -/* -**/* -* -!src/main/java/test/test-java-infra/infra/__functions.java -", - ".pdk/dynamic-files/openapitools.json": { - "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", - "generator-cli": { - "storageDir": "~/.open-api-generator-cli", - "version": "6.3.0", - }, - "spaces": 2, - }, ".projen/deps.json": { "//": "~~ Generated by projen. To modify, edit src/test/java/projenrc.java and run "npx projen".", "dependencies": [ @@ -237,9 +206,6 @@ dist/java ".gitattributes", ".github/workflows/pull-request-lint.yml", ".gitignore", - ".openapi-generator-ignore", - ".openapi-generator-ignore-handlebars", - ".pdk/dynamic-files/openapitools.json", ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", @@ -317,14 +283,6 @@ dist/java }, ], }, - "create-openapitools.json": { - "name": "create-openapitools.json", - "steps": [ - { - "exec": "cp -f .pdk/dynamic-files/openapitools.json openapitools.json", - }, - ], - }, "default": { "description": "Synthesize project files", "name": "default", @@ -353,13 +311,7 @@ dist/java "name": "generate", "steps": [ { - "spawn": "create-openapitools.json", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.clean-openapi-generated-code --code-path .", - }, - { - "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api.generate --generator java --spec-path my-spec.json --output-path . --generator-dir java-cdk-infrastructure --src-dir src/main/java/test/test-java-infra/infra --tst-dir test --openapi-normalizer "KEEP_ONLY_FIRST_TAG_IN_OPERATION=true" --extra-vendor-extensions '{"x-infrastructure-package":"test.test-java-infra.infra","x-runtime-package":"test.test-java-client.runtime","x-enable-mock-integrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", + "exec": "npx --yes -p @aws/pdk@$AWS_PDK_VERSION type-safe-api generate --specPath my-spec.json --outputPath . --templateDirs "java-cdk-infrastructure" --metadata '{"srcDir":"src/main/java/test/test-java-infra/infra","packageName":"test.test-java-infra.infra","runtimePackageName":"test.test-java-client.runtime","enableMockIntegrations":true,"x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}'", }, { "exec": "mkdir -p src/main/resources", diff --git a/packages/type-safe-api/test/scripts/generators/__snapshots__/java-cdk-infrastructure.test.ts.snap b/packages/type-safe-api/test/scripts/generators/__snapshots__/java-cdk-infrastructure.test.ts.snap index d3b517e19..dd4a202c8 100644 --- a/packages/type-safe-api/test/scripts/generators/__snapshots__/java-cdk-infrastructure.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/__snapshots__/java-cdk-infrastructure.test.ts.snap @@ -137,7 +137,6 @@ public class JavaOneFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -275,7 +274,6 @@ public class JavaTwoFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -413,7 +411,6 @@ public class PythonOneFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -551,7 +548,6 @@ public class PythonTwoFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -689,7 +685,6 @@ public class TypescriptOneFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -969,7 +964,6 @@ public class JavaTestFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -1107,7 +1101,6 @@ public class PythonTestFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -1294,10 +1287,7 @@ public class MockIntegrations { } } - - // No mock integrations have been generated, since mock data generation is disabled. - } " `; @@ -1472,7 +1462,6 @@ public class MockIntegrations { } } - /** * Mock integration to return a 200 response from the anyRequestResponse operation */ @@ -1611,8 +1600,6 @@ public class MockIntegrations { .build()) ; } - - } " `; diff --git a/packages/type-safe-api/test/scripts/generators/__snapshots__/java-lambda-handlers.test.ts.snap b/packages/type-safe-api/test/scripts/generators/__snapshots__/java-lambda-handlers.test.ts.snap index f746eeaff..e7704bbf9 100644 --- a/packages/type-safe-api/test/scripts/generators/__snapshots__/java-lambda-handlers.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/__snapshots__/java-lambda-handlers.test.ts.snap @@ -139,8 +139,6 @@ public class JavaTwoHandler extends JavaTwo { } } - - " `; @@ -221,7 +219,5 @@ public class JavaTwoHandlerTest { } } - - " `; diff --git a/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-cdk-infrastructure.test.ts.snap b/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-cdk-infrastructure.test.ts.snap index 04db55c9e..bf2d8e4f6 100644 --- a/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-cdk-infrastructure.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-cdk-infrastructure.test.ts.snap @@ -137,7 +137,6 @@ public class JavaOneFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -275,7 +274,6 @@ public class JavaTwoFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -413,7 +411,6 @@ public class PythonOneFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -551,7 +548,6 @@ public class PythonTwoFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -689,7 +685,6 @@ public class TypescriptOneFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -969,7 +964,6 @@ public class JavaFunctionProps implements SnapStartFunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -1107,7 +1101,6 @@ public class PythonFunctionProps implements FunctionProps { IDestination onSuccess; Number retryAttempts; } - ", ], [ @@ -1420,10 +1413,7 @@ public class MockIntegrations { } } - - // No mock integrations have been generated, since mock data generation is disabled. - } " `; diff --git a/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-lambda-handlers.test.ts.snap b/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-lambda-handlers.test.ts.snap index 0de97de89..ec574f824 100644 --- a/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-lambda-handlers.test.ts.snap +++ b/packages/type-safe-api/test/scripts/generators/async/__snapshots__/java-lambda-handlers.test.ts.snap @@ -139,8 +139,6 @@ public class JavaTwoHandler extends JavaTwo { } } - - " `; @@ -221,7 +219,5 @@ public class JavaTwoHandlerTest { } } - - " `; diff --git a/packages/type-safe-api/test/scripts/generators/async/java-cdk-infrastructure.test.ts b/packages/type-safe-api/test/scripts/generators/async/java-cdk-infrastructure.test.ts index c58786905..599e0541d 100644 --- a/packages/type-safe-api/test/scripts/generators/async/java-cdk-infrastructure.test.ts +++ b/packages/type-safe-api/test/scripts/generators/async/java-cdk-infrastructure.test.ts @@ -4,7 +4,6 @@ import os from "os"; import * as path from "path"; import { exec } from "projen/lib/util"; import { getTestHandlerProjects } from "./utils"; -import { OpenApiToolsJsonFile } from "../../../../src/project/codegen/components/open-api-tools-json-file"; import { GeneratedJavaAsyncCdkInfrastructureProject } from "../../../../src/project/codegen/infrastructure/cdk/generated-java-async-cdk-infrastructure-project"; import { GeneratedJavaAsyncRuntimeProject } from "../../../../src/project/codegen/runtime/generated-java-async-runtime-project"; import { withTmpDirSnapshot } from "../../../project/snapshot-utils"; @@ -42,17 +41,11 @@ describe("Java Async Infrastructure Code Generation Script Unit Tests", () => { generatedJavaTypes: client, generatedHandlers: {}, }); - // Synth the openapitools.json since it's used by the generate command - OpenApiToolsJsonFile.of(project)!.synthesize(); exec(`mkdir -p ${infraOutdir}`, { cwd: outdir }); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: infraOutdir } - ); exec( `${path.resolve( __dirname, - "../../../../scripts/type-safe-api/generators/generate" + "../../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: infraOutdir, @@ -60,7 +53,6 @@ describe("Java Async Infrastructure Code Generation Script Unit Tests", () => { ); }, { - excludeGlobs: GeneratedJavaAsyncRuntimeProject.openApiIgnorePatterns, parseJson: false, } ); @@ -107,14 +99,10 @@ describe("Java Async Infrastructure Code Generation Script Unit Tests", () => { generatedHandlers: handlers, }); project.synth(); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: infraOutdir } - ); exec( `${path.resolve( __dirname, - "../../../../scripts/type-safe-api/generators/generate" + "../../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: infraOutdir, @@ -122,7 +110,6 @@ describe("Java Async Infrastructure Code Generation Script Unit Tests", () => { ); }, { - excludeGlobs: GeneratedJavaAsyncRuntimeProject.openApiIgnorePatterns, parseJson: false, } ); diff --git a/packages/type-safe-api/test/scripts/generators/async/java-lambda-handlers.test.ts b/packages/type-safe-api/test/scripts/generators/async/java-lambda-handlers.test.ts index 27d24bbd9..e16fc3b53 100644 --- a/packages/type-safe-api/test/scripts/generators/async/java-lambda-handlers.test.ts +++ b/packages/type-safe-api/test/scripts/generators/async/java-lambda-handlers.test.ts @@ -40,14 +40,10 @@ describe("Java Async Handlers Code Generation Script Unit Tests", () => { generatedJavaTypes: runtime, }); project.synth(); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: handlersOutdir } - ); exec( `${path.resolve( __dirname, - "../../../../scripts/type-safe-api/generators/generate" + "../../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: handlersOutdir, diff --git a/packages/type-safe-api/test/scripts/generators/java-cdk-infrastructure.test.ts b/packages/type-safe-api/test/scripts/generators/java-cdk-infrastructure.test.ts index ee5ac8217..b07f2de3b 100644 --- a/packages/type-safe-api/test/scripts/generators/java-cdk-infrastructure.test.ts +++ b/packages/type-safe-api/test/scripts/generators/java-cdk-infrastructure.test.ts @@ -4,7 +4,6 @@ import os from "os"; import * as path from "path"; import { exec } from "projen/lib/util"; import { getTestHandlerProjects } from "./utils"; -import { OpenApiToolsJsonFile } from "../../../src/project/codegen/components/open-api-tools-json-file"; import { GeneratedJavaCdkInfrastructureProject } from "../../../src/project/codegen/infrastructure/cdk/generated-java-cdk-infrastructure-project"; import { GeneratedJavaRuntimeProject } from "../../../src/project/codegen/runtime/generated-java-runtime-project"; import { withTmpDirSnapshot } from "../../project/snapshot-utils"; @@ -39,17 +38,11 @@ describe("Java Infrastructure Code Generation Script Unit Tests", () => { generatedJavaTypes: client, generatedHandlers: {}, }); - // Synth the openapitools.json since it's used by the generate command - OpenApiToolsJsonFile.of(project)!.synthesize(); exec(`mkdir -p ${infraOutdir}`, { cwd: outdir }); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: infraOutdir } - ); exec( `${path.resolve( __dirname, - "../../../scripts/type-safe-api/generators/generate" + "../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: infraOutdir, @@ -57,7 +50,6 @@ describe("Java Infrastructure Code Generation Script Unit Tests", () => { ); }, { - excludeGlobs: GeneratedJavaRuntimeProject.openApiIgnorePatterns, parseJson: false, } ); @@ -110,17 +102,11 @@ describe("Java Infrastructure Code Generation Script Unit Tests", () => { }, generatedHandlers: {}, }); - // Synth the openapitools.json since it's used by the generate command - OpenApiToolsJsonFile.of(project)!.synthesize(); exec(`mkdir -p ${infraOutdir}`, { cwd: outdir }); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: infraOutdir } - ); exec( `${path.resolve( __dirname, - "../../../scripts/type-safe-api/generators/generate" + "../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: infraOutdir, @@ -169,14 +155,10 @@ describe("Java Infrastructure Code Generation Script Unit Tests", () => { generatedHandlers: handlers, }); project.synth(); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: infraOutdir } - ); exec( `${path.resolve( __dirname, - "../../../scripts/type-safe-api/generators/generate" + "../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: infraOutdir, @@ -184,7 +166,6 @@ describe("Java Infrastructure Code Generation Script Unit Tests", () => { ); }, { - excludeGlobs: GeneratedJavaRuntimeProject.openApiIgnorePatterns, parseJson: false, } ); diff --git a/packages/type-safe-api/test/scripts/generators/java-lambda-handlers.test.ts b/packages/type-safe-api/test/scripts/generators/java-lambda-handlers.test.ts index 0be7430e7..86e4f4588 100644 --- a/packages/type-safe-api/test/scripts/generators/java-lambda-handlers.test.ts +++ b/packages/type-safe-api/test/scripts/generators/java-lambda-handlers.test.ts @@ -37,14 +37,10 @@ describe("Java Handlers Code Generation Script Unit Tests", () => { generatedJavaTypes: runtime, }); project.synth(); - exec( - project.tasks.tryFind("create-openapitools.json")!.steps[0].exec!, - { cwd: handlersOutdir } - ); exec( `${path.resolve( __dirname, - "../../../scripts/type-safe-api/generators/generate" + "../../../scripts/type-safe-api/run.js generate" )} ${project.buildGenerateCommandArgs()}`, { cwd: handlersOutdir,