diff --git a/e2e/src/test/resources/projects/customer-address-postgres-json/pom.xml b/e2e/src/test/resources/projects/customer-address-postgres-json/pom.xml index aa935be6..7e2fd502 100644 --- a/e2e/src/test/resources/projects/customer-address-postgres-json/pom.xml +++ b/e2e/src/test/resources/projects/customer-address-postgres-json/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.3.1 io.zenwave360.example @@ -47,6 +47,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.boot spring-boot-starter-security @@ -144,7 +148,7 @@ org.openapitools openapi-generator-maven-plugin - 6.6.0 + 7.8.0 @@ -158,9 +162,7 @@ io.zenwave360.example.adapters.web.model DTO true - - ApiUtil.java - + false Double=java.math.BigDecimal @@ -171,7 +173,9 @@ true true true + true false + false diff --git a/e2e/src/test/resources/projects/customer-address-relational/pom.xml b/e2e/src/test/resources/projects/customer-address-relational/pom.xml index 7c01b5e6..5db5954c 100644 --- a/e2e/src/test/resources/projects/customer-address-relational/pom.xml +++ b/e2e/src/test/resources/projects/customer-address-relational/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.3.1 io.zenwave360.example @@ -47,6 +47,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.boot spring-boot-starter-security @@ -140,7 +144,7 @@ org.openapitools openapi-generator-maven-plugin - 6.6.0 + 7.8.0 @@ -154,9 +158,7 @@ io.zenwave360.example.adapters.web.model DTO true - - ApiUtil.java - + false Double=java.math.BigDecimal @@ -167,7 +169,9 @@ true true true + true false + false diff --git a/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml b/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml index 9cce69c2..b8e50f63 100644 --- a/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml +++ b/e2e/src/test/resources/projects/online-food-delivery-mongo/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.1 + 3.3.1 pom @@ -134,7 +134,7 @@ org.openapitools openapi-generator-maven-plugin - 6.6.0 + 7.8.0 openapi-generator-server @@ -149,9 +149,7 @@ ${basePackage}.adapters.web.model DTO true - - ApiUtil.java - + false Double=java.math.BigDecimal @@ -162,7 +160,9 @@ true true true + true false + false @@ -182,6 +182,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.boot spring-boot-starter-security diff --git a/e2e/src/test/resources/projects/simple-domain-packaging/pom.xml b/e2e/src/test/resources/projects/simple-domain-packaging/pom.xml index be9fb79f..2ccb37cd 100644 --- a/e2e/src/test/resources/projects/simple-domain-packaging/pom.xml +++ b/e2e/src/test/resources/projects/simple-domain-packaging/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.3.1 io.zenwave360.example @@ -47,6 +47,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.boot spring-boot-starter-security @@ -140,7 +144,7 @@ org.openapitools openapi-generator-maven-plugin - 6.6.0 + 7.8.0 @@ -154,9 +158,7 @@ io.zenwave360.example.customer.dtos DTO true - - ApiUtil.java - + false Double=java.math.BigDecimal @@ -167,7 +169,9 @@ true true true + true false + false diff --git a/plugins/asyncapi-spring-cloud-streams3/README.md b/plugins/asyncapi-spring-cloud-streams3/README.md index 6404aea6..ff77031f 100644 --- a/plugins/asyncapi-spring-cloud-streams3/README.md +++ b/plugins/asyncapi-spring-cloud-streams3/README.md @@ -82,6 +82,8 @@ jbang zw -p io.zenwave360.sdk.plugins.SpringCloudStreams3Plugin --help | `exposeMessage` | Whether to expose underlying spring Message to consumers or not. | boolean | false | | | `apiPackage` | Java API package name for producerApiPackage and consumerApiPackage if not specified. | String | | | | `modelPackage` | Java Models package name | String | | | +| `modelNamePrefix` | Sets the prefix for model classes and enums | String | | | +| `modelNameSuffix` | Sets the suffix for model classes and enums | String | | | | `producerApiPackage` | Java API package name for outbound (producer) services. It can override apiPackage for producers. | String | {{apiPackage}} | | | `consumerApiPackage` | Java API package name for inbound (consumer) services. It can override apiPackage for consumer. | String | {{apiPackage}} | | | `bindingTypes` | Binding names to include in code generation. Generates code for ALL bindings if left empty | List | | | diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/domain/jpa/partials/id/postgresql.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/domain/jpa/partials/id/postgresql.hbs index 1517a8ed..10f4d16b 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/domain/jpa/partials/id/postgresql.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/domain/jpa/partials/id/postgresql.hbs @@ -1,3 +1,2 @@ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - @SequenceGenerator(name = "sequenceGenerator") diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/ArchitectureTest.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/ArchitectureTest.java.hbs index ae429864..53dac8a1 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/ArchitectureTest.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/ArchitectureTest.java.hbs @@ -12,7 +12,7 @@ import static com.tngtech.archunit.library.Architectures.layeredArchitecture; import static com.tngtech.archunit.library.Architectures.onionArchitecture; @AnalyzeClasses(packages = "{{basePackage}}", importOptions = DoNotIncludeTests.class) -public class ArchitectureTest { +class ArchitectureTest { /** * Validates that dependencies between layers respect hexagonal/onion/clean architecture. diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-jpa.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-jpa.java.hbs index 03883eb8..df083df9 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-jpa.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-jpa.java.hbs @@ -88,7 +88,7 @@ public class DockerComposeInitializer implements ApplicationContextInitializer { try { - return getDockerComposeRunningServices(cmd, "-f", DOCKER_COMPOSE_FILE, "ps").containsAll(serviceNames); + return getDockerComposeRunningServices(cmd, "-f", DOCKER_COMPOSE_FILE, "ps", "--services").containsAll(serviceNames); } catch (IOException | InterruptedException e) { return false; @@ -104,16 +104,13 @@ public class DockerComposeInitializer implements ApplicationContextInitializer SERVICE_COLUMN) { - services.add(columns[SERVICE_COLUMN]); - } - } + if (!line.isEmpty()) { + services.add(line); + } } process.waitFor(); - return services.size() > 1? services.subList(1, services.size()) : services; + return services; } boolean isPortOpen(String host, int port) { diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-mongodb.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-mongodb.java.hbs index a53a8882..122c276f 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-mongodb.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/DockerComposeInitializer-mongodb.java.hbs @@ -88,7 +88,7 @@ public class DockerComposeInitializer implements ApplicationContextInitializer { try { - return getDockerComposeRunningServices(cmd, "-f", DOCKER_COMPOSE_FILE, "ps").containsAll(serviceNames); + return getDockerComposeRunningServices(cmd, "-f", DOCKER_COMPOSE_FILE, "ps", "--services").containsAll(serviceNames); } catch (IOException | InterruptedException e) { return false; @@ -96,7 +96,6 @@ public class DockerComposeInitializer implements ApplicationContextInitializer getDockerComposeRunningServices(String... command) throws IOException, InterruptedException { List services = new ArrayList<>(); var process = new ProcessBuilder(command).start(); @@ -104,16 +103,13 @@ public class DockerComposeInitializer implements ApplicationContextInitializer SERVICE_COLUMN) { - services.add(columns[SERVICE_COLUMN]); - } - } + if (!line.isEmpty()) { + services.add(line); + } } process.waitFor(); - return services.size() > 1? services.subList(1, services.size()) : services; + return services; } boolean isPortOpen(String host, int port) { diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/TestDataLoader-jpa.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/TestDataLoader-jpa.java.hbs index 09994b47..6a266c86 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/TestDataLoader-jpa.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/config/TestDataLoader-jpa.java.hbs @@ -1,6 +1,7 @@ package {{basePackage}}.config; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.persistence.Table; @@ -15,7 +16,10 @@ public class TestDataLoader { private List> jpaManagedTypes; - private ObjectMapper objectMapper = new ObjectMapper(); + private final ObjectMapper objectMapper = new ObjectMapper(); + { + objectMapper.registerModule(new JavaTimeModule()); + } public TestDataLoader(List> jpaManagedTypes) { this.jpaManagedTypes = jpaManagedTypes; diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/jpa/imperative/ServiceTest.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/jpa/imperative/ServiceTest.java.hbs index 6f91a924..0d29bc3b 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/jpa/imperative/ServiceTest.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/jpa/imperative/ServiceTest.java.hbs @@ -29,7 +29,7 @@ import static org.mockito.Mockito.*; /** * Acceptance Test for {{service.name}}. */ -public class {{service.name}}Test { +class {{service.name}}Test { private final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/mongodb/imperative/ServiceTest.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/mongodb/imperative/ServiceTest.java.hbs index 130b935a..02de272c 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/mongodb/imperative/ServiceTest.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/core/implementation/mongodb/imperative/ServiceTest.java.hbs @@ -28,7 +28,7 @@ import static org.mockito.Mockito.*; /** * Acceptance Test for {{service.name}}. */ -public class {{service.name}}Test { +class {{service.name}}Test { private final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/jpa/imperative/EntityRepositoryIntegrationTest.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/jpa/imperative/EntityRepositoryIntegrationTest.java.hbs index d5101717..a674c150 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/jpa/imperative/EntityRepositoryIntegrationTest.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/jpa/imperative/EntityRepositoryIntegrationTest.java.hbs @@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import jakarta.persistence.EntityManager; -public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest { +class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest { @Autowired EntityManager entityManager; @@ -22,26 +22,26 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor {{entity.className}}Repository {{entity.instanceName}}Repository; @Test - public void findAllTest() { + void findAllTest() { var results = {{entity.instanceName}}Repository.findAll(); Assertions.assertFalse(results.isEmpty()); } @Test - public void findByIdTest() { + void findByIdTest() { var id = 1L; var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow(); - Assertions.assertTrue({{entity.instanceName}}.getId() != null); - Assertions.assertTrue({{entity.instanceName}}.getVersion() != null); + Assertions.assertNotNull({{entity.instanceName}}.getId()); + Assertions.assertNotNull({{entity.instanceName}}.getVersion()); {{~#if (or entity.options.auditing entity.options.extendsAuditing)}} - Assertions.assertTrue({{entity.instanceName}}.getCreatedBy() != null); - Assertions.assertTrue({{entity.instanceName}}.getCreatedDate() != null); + Assertions.assertNotNull({{entity.instanceName}}.getCreatedBy()); + Assertions.assertNotNull({{entity.instanceName}}.getCreatedDate()); {{~/if}} } @Test - public void saveTest() { + void saveTest() { {{entity.className}} {{entity.instanceName}} = new {{entity.className}}(); {{~#each entity.fields as |field|}} {{entity.instanceName}}.set{{capitalize field.name}}({{{populateField field}}}); @@ -79,18 +79,18 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor // reloading to get relationships persisted by id entityManager.flush(); entityManager.refresh(created); - Assertions.assertTrue(created.getId() != null); - Assertions.assertTrue(created.getVersion() != null); + Assertions.assertNotNull(created.getId()); + Assertions.assertNotNull(created.getVersion()); {{~#if (or entity.options.auditing entity.options.extendsAuditing)}} - Assertions.assertTrue(created.getCreatedBy() != null); - Assertions.assertTrue(created.getCreatedDate() != null); + Assertions.assertNotNull(created.getCreatedBy()); + Assertions.assertNotNull(created.getCreatedDate()); {{~/if}} {{#each entity.relationships as |relationship|}} {{~#if relationship.fieldName}} {{~#if relationship.ownerSide}} {{~#if (endsWith relationship.type 'OneToOne')}} - Assertions.assertTrue({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() != null); + Assertions.assertNotNull({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() != null); {{~else if (endsWith relationship.type 'ToOne')}} Assertions.assertTrue({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() == {{relationship.fieldName}}Id); {{~else}} @@ -102,7 +102,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor } @Test - public void updateTest() { + void updateTest() { var id = 1L; var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow(); {{~#each entity.fields as |field|}} @@ -116,7 +116,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor } @Test - public void deleteTest() { + void deleteTest() { var id = 1L; {{entity.instanceName}}Repository.deleteById(id); var notFound = {{entity.instanceName}}Repository.findById(id); diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/mongodb/imperative/EntityRepositoryIntegrationTest.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/mongodb/imperative/EntityRepositoryIntegrationTest.java.hbs index 2c5cbdf1..10a5a52d 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/mongodb/imperative/EntityRepositoryIntegrationTest.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/test/java/infrastructure/mongodb/imperative/EntityRepositoryIntegrationTest.java.hbs @@ -6,20 +6,20 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest { +class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest { @Autowired {{entity.className}}Repository {{entity.instanceName}}Repository; @Test - public void findAllTest() { + void findAllTest() { var results = {{entity.instanceName}}Repository.findAll(); Assertions.assertFalse(results.isEmpty()); } @Test - public void findByIdTest() { + void findByIdTest() { var id = "1"; var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow(); Assertions.assertTrue({{entity.instanceName}}.getId() != null); @@ -30,7 +30,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor } @Test - public void saveTest() { + void saveTest() { {{entity.className}} {{entity.instanceName}} = new {{entity.className}}(); {{~#each entity.fields as |field|}} {{entity.instanceName}}.set{{capitalize field.name}}(null); @@ -45,7 +45,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor } @Test - public void updateTest() { + void updateTest() { var id = "1"; var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow(); {{~#each entity.fields as |field|}} @@ -59,7 +59,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor } @Test - public void deleteTest() { + void deleteTest() { var id = "1"; {{entity.instanceName}}Repository.deleteById(id); var notFound = {{entity.instanceName}}Repository.findById(id); diff --git a/plugins/backend-application-default/src/test/resources/jpa-elasticsearch-scs3-pom.xml b/plugins/backend-application-default/src/test/resources/jpa-elasticsearch-scs3-pom.xml index 375a6c51..1c792924 100644 --- a/plugins/backend-application-default/src/test/resources/jpa-elasticsearch-scs3-pom.xml +++ b/plugins/backend-application-default/src/test/resources/jpa-elasticsearch-scs3-pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.3.1 tests @@ -76,6 +76,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.cloud spring-cloud-starter-stream-kafka diff --git a/plugins/backend-application-default/src/test/resources/mongodb-elasticsearch-scs3-pom.xml b/plugins/backend-application-default/src/test/resources/mongodb-elasticsearch-scs3-pom.xml index 79887e20..c425f409 100644 --- a/plugins/backend-application-default/src/test/resources/mongodb-elasticsearch-scs3-pom.xml +++ b/plugins/backend-application-default/src/test/resources/mongodb-elasticsearch-scs3-pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.3.1 tests @@ -76,6 +76,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-json + org.springframework.cloud spring-cloud-starter-stream-kafka diff --git a/plugins/openapi-controllers/README.md b/plugins/openapi-controllers/README.md index 012db7fa..d707d0b7 100644 --- a/plugins/openapi-controllers/README.md +++ b/plugins/openapi-controllers/README.md @@ -16,7 +16,62 @@ jbang zw -p io.zenwave360.sdk.plugins.OpenAPIControllersPlugin targetFolder=. ``` -## Options +## Configuring OpenAPI Generator for Compatibility + +Default options for https://openapi-generator.tech/docs/generators/spring/ have changes over time and different versions. Here is a sample configuration that works with this version of ZenWave360 SDK. + +```xml + + org.openapitools + openapi-generator-maven-plugin + 7.8.0 + + + + generate + + generate-sources + + ${project.basedir}/src/main/resources/public/apis/openapi.yml + true + spring + ${openApiApiPackage} + ${openApiModelPackage} + DTO + true + false + + Double=java.math.BigDecimal + + + true + none + false + true + true + true + true + false + false + + + + + +``` + +Also, make sure you set `required: true` for `requestBody` in your OpenAPI definition for post, put, patch... + +```yaml +requestBody: + required: true # this is important + content: + application/json: + schema: + $ref: "#/components/schemas/Customer" +``` + +## Plugin Options | **Option** | **Description** | **Type** | **Default** | **Values** | |-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|---------------------------------------|-----------------------------------| @@ -42,7 +97,6 @@ jbang zw -p io.zenwave360.sdk.plugins.OpenAPIControllersPlugin | `haltOnFailFormatting` | Halt on formatting errors | boolean | true | | | `continueOnZdlError` | Continue even when ZDL contains fatal errors | boolean | true | | - ## Getting Help ```shell diff --git a/plugins/openapi-controllers/src/main/resources/io/zenwave360/sdk/plugins/OpenAPIControllersGenerator/src/main/java/web/mvc/ServiceApiController.java.hbs b/plugins/openapi-controllers/src/main/resources/io/zenwave360/sdk/plugins/OpenAPIControllersGenerator/src/main/java/web/mvc/ServiceApiController.java.hbs index c19d56fd..7cd79abe 100644 --- a/plugins/openapi-controllers/src/main/resources/io/zenwave360/sdk/plugins/OpenAPIControllersGenerator/src/main/java/web/mvc/ServiceApiController.java.hbs +++ b/plugins/openapi-controllers/src/main/resources/io/zenwave360/sdk/plugins/OpenAPIControllersGenerator/src/main/java/web/mvc/ServiceApiController.java.hbs @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.web.context.request.NativeWebRequest; @@ -56,7 +57,6 @@ public class {{serviceName}}ApiController implements {{serviceName}}Api { {{/joinWithTemplate}} } - @Override public Optional getRequest() { return Optional.ofNullable(request); } @@ -102,6 +102,12 @@ public class {{serviceName}}ApiController implements {{serviceName}}Api { {{~/each}} protected Pageable pageOf(Optional page, Optional limit, Optional> sort) { - return PageRequest.of(page.orElse(0), limit.orElse(10)); + Sort sortOrder = sort.map(s -> Sort.by(s.stream().map(sortParam -> { + String[] parts = sortParam.split(":"); + String property = parts[0]; + Sort.Direction direction = parts.length > 1 ? Sort.Direction.fromString(parts[1]) : Sort.Direction.ASC; + return new Sort.Order(direction, property); + }).toList())).orElse(Sort.unsorted()); + return PageRequest.of(page.orElse(0), limit.orElse(10), sortOrder); } } diff --git a/plugins/zdl-to-openapi/src/main/resources/io/zenwave360/sdk/plugins/ZDLToOpenAPIGenerator/ZDLToOpenAPI.yml.hbs b/plugins/zdl-to-openapi/src/main/resources/io/zenwave360/sdk/plugins/ZDLToOpenAPIGenerator/ZDLToOpenAPI.yml.hbs index 4ba0d684..72cf1e76 100644 --- a/plugins/zdl-to-openapi/src/main/resources/io/zenwave360/sdk/plugins/ZDLToOpenAPIGenerator/ZDLToOpenAPI.yml.hbs +++ b/plugins/zdl-to-openapi/src/main/resources/io/zenwave360/sdk/plugins/ZDLToOpenAPIGenerator/ZDLToOpenAPI.yml.hbs @@ -66,6 +66,7 @@ paths: {{~/if}} {{~#if (and operation.requestBody (or (eq operation.httpMethod 'post') (eq operation.httpMethod 'put') (eq operation.httpMethod 'patch') ))}} requestBody: + required: true content: application/json: schema: diff --git a/zenwave-sdk-cli/src/main/java/io/zenwave360/sdk/processors/AsyncApiProcessor.java b/zenwave-sdk-cli/src/main/java/io/zenwave360/sdk/processors/AsyncApiProcessor.java index 5741a43d..b9118217 100644 --- a/zenwave-sdk-cli/src/main/java/io/zenwave360/sdk/processors/AsyncApiProcessor.java +++ b/zenwave-sdk-cli/src/main/java/io/zenwave360/sdk/processors/AsyncApiProcessor.java @@ -72,6 +72,12 @@ public String getSchemaFormat(String asyncApiVersion) { } + @DocumentedOption(description = "Sets the prefix for model classes and enums") + public String modelNamePrefix = ""; + + @DocumentedOption(description = "Sets the suffix for model classes and enums") + public String modelNameSuffix = ""; + @DocumentedOption(description = "AsyncAPI extension property name for runtime autoconfiguration of headers.") public String runtimeHeadersProperty = "x-runtime-expression"; @@ -228,6 +234,7 @@ public void calculateMessageParamType(Map apiModel, Map