generator-nokode 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,9 @@
1
1
  package <%=packageName%>.config.openapi;
2
2
 
3
+ import java.util.HashSet;
4
+ import java.util.Map;
5
+ import java.util.Set;
6
+
3
7
  import org.springdoc.core.customizers.OperationCustomizer;
4
8
  import org.springframework.context.annotation.Bean;
5
9
  import org.springframework.context.annotation.Configuration;
@@ -8,10 +12,12 @@ import org.springframework.web.method.HandlerMethod;
8
12
  import <%=packageName%>.config.constants.<%=appNameTitleCase%>Constants;
9
13
  import io.swagger.v3.oas.models.Components;
10
14
  import io.swagger.v3.oas.models.OpenAPI;
15
+ import org.springdoc.core.customizers.OpenApiCustomizer;
11
16
  import io.swagger.v3.oas.models.Operation;
12
17
  import io.swagger.v3.oas.models.info.Info;
13
18
  import io.swagger.v3.oas.models.security.SecurityRequirement;
14
19
  import io.swagger.v3.oas.models.security.SecurityScheme;
20
+ import io.swagger.v3.oas.models.media.Schema;
15
21
 
16
22
  @Configuration
17
23
  public class OpenAPIConfig {
@@ -19,7 +25,7 @@ public class OpenAPIConfig {
19
25
  @Bean
20
26
  OpenAPI customOpenAPI() {
21
27
  return new OpenAPI()
22
- .info(new Info().title("<%= appName %> API").version("1.0.0"))
28
+ .info(new Info().title("<%= appName %>").version("1.0.0"))
23
29
  .components(new Components()
24
30
  .addSecuritySchemes("JWT", new SecurityScheme()
25
31
  .type(SecurityScheme.Type.APIKEY)
@@ -45,4 +51,31 @@ public class OpenAPIConfig {
45
51
  return c;
46
52
  }
47
53
 
54
+ @Bean
55
+ OpenApiCustomizer nullableOptionalFieldsCustomizer() {
56
+ return new OpenApiCustomizer() {
57
+ @Override
58
+ @SuppressWarnings({"rawtypes", "unchecked"})
59
+ public void customise(OpenAPI openApi) {
60
+ if (openApi.getComponents() != null && openApi.getComponents().getSchemas() != null) {
61
+ for (Schema schema : openApi.getComponents().getSchemas().values()) {
62
+ if (schema.getProperties() == null) {
63
+ continue;
64
+ }
65
+ ((Map<String, Schema>) schema.getProperties()).forEach((String name, Schema value) -> {
66
+ if (schema.getRequired() == null || !schema.getRequired().contains(name)) {
67
+ Set<String> types = value.getTypes();
68
+ if (types == null) {
69
+ types = new HashSet<>();
70
+ }
71
+ types.add("null");
72
+ value.setTypes(types);
73
+ }
74
+ });
75
+ }
76
+ }
77
+ }
78
+ };
79
+ }
80
+
48
81
  }
@@ -3,8 +3,8 @@
3
3
  SPRING_BOOT_VERSION: '3.5.5',
4
4
  SPRING_PLUGIN_VERSION: '1.1.7',
5
5
  SPRINGDOC_PLUGIN_VERSION: '1.9.0',
6
- SPRINGDOC_OPENAPI_VERSION: '2.8.9',
7
- SIXSPRINTS_AUTH_VERSION: '3.5.508',
6
+ SPRINGDOC_OPENAPI_VERSION: '2.8.13',
7
+ SIXSPRINTS_AUTH_VERSION: '3.5.513',
8
8
  SIXSPRINTS_CLOUD_STORAGE_API_VERSION: '2.0.1',
9
9
  MAPSTRUCT_VERSION: '1.6.3',
10
10
  LOMBOK_MAPSTRUCT_BINDING_VERSION: '0.2.0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-nokode",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A Yeoman generator for creating Spring Boot applications with Nokode framework",
5
5
  "main": "index.js",
6
6
  "type": "module",