Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.

Commit c83248b

Browse files
committed
[1.0.0] - 2023-11-30
- handling of template version (currently 0 - legacy, 1, this release) - handling of constraints minLength, maxLength, minimum and maximum for [OpenAPI data types](https://swagger.io/docs/specification/data-models/data-types/) - parent changed from fj-bom to fj-universe-tool 0.5.6
1 parent 8a2257d commit c83248b

File tree

13 files changed

+131
-14
lines changed

13 files changed

+131
-14
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.0] - 2023-11-30
11+
12+
### Added
13+
14+
- handling of template version (currently 0 - legacy, 1, this release)
15+
- handling of constraints minLength, maxLength, minimum and maximum for [OpenAPI data types](https://swagger.io/docs/specification/data-models/data-types/)
16+
1017
### Changed
1118

1219
- parent changed from fj-bom to fj-universe-tool 0.5.6

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,17 @@ java -jar dist-yaml-doc-tool-*.jar --mode [check-model] \
7373
--output-file [output-file] \
7474
--check-type [java type to check] \
7575
--check-schema [openapi schema to check]
76+
--version [model-version]
7677
```
78+
79+
## Model version info (param "version")
80+
81+
### Version 0 - legacy version (up to 1.0.0 excluded)
82+
83+
### Version 1
84+
85+
handling handling of constraints [OpenAPI data types](https://swagger.io/docs/specification/data-models/data-types/)
86+
- minLength
87+
- maxLength
88+
- minimum
89+
- maximum

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<relativePath></relativePath>
1313
</parent>
1414

15-
<version>0.7.0</version>
15+
<version>1.0.0</version>
1616
<packaging>jar</packaging>
1717

1818
<name>yaml-doc-tool</name>

src/main/java/org/fugerit/java/yaml/doc/YamlDocConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@
55

66
public class YamlDocConfig {
77

8+
public static final Integer VERSION_0 = 0;
9+
public static final Integer VERSION_1 = 1;
10+
public static final Integer VERSION_DEFAULT = VERSION_1; // default version is last version
11+
812
public YamlDocConfig() {
913
this.locale = Locale.getDefault();
1014
if ( this.locale == null ) {
1115
this.locale = Locale.ENGLISH;
1216
}
17+
this.version = VERSION_DEFAULT;
1318
this.labelsOverride = new Properties();
1419
}
1520

1621
private String outputFormat;
22+
23+
private Integer version;
1724

1825
public String getOutputFormat() {
1926
return outputFormat;
@@ -91,5 +98,13 @@ public boolean isUseOpenapiTitle() {
9198
public void setUseOpenapiTitle(boolean useOpenapiTitle) {
9299
this.useOpenapiTitle = useOpenapiTitle;
93100
}
101+
102+
public Integer getVersion() {
103+
return version;
104+
}
105+
106+
public void setVersion(Integer version) {
107+
this.version = version;
108+
}
94109

95110
}

src/main/java/org/fugerit/java/yaml/doc/YamlDocMain.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ private YamlDocMain() {}
5454

5555
public static final String ARG_USE_OPENAPI_TITLE = "use-openapi-title";
5656

57+
public static final String ARG_VERSION = "version";
58+
5759
private static void addIfNotEmpty( Properties props, String key, String value ) {
5860
if ( StringUtils.isNotEmpty( value ) ) {
5961
props.setProperty( key , value );
@@ -66,6 +68,7 @@ private static void setup( YamlDocConfig config, Properties props ) throws IOExc
6668
String excludePaths = props.getProperty( ARG_EXCLUDE_PATHS );
6769
String excludeSchemas = props.getProperty( ARG_EXCLUDE_SCHEMAS );
6870
String useOpenapiTitle = props.getProperty( ARG_USE_OPENAPI_TITLE );
71+
String version = props.getProperty( ARG_VERSION );
6972
if ( StringUtils.isNotEmpty( language ) ) {
7073
config.setLocale( Locale.forLanguageTag( language ) );
7174
}
@@ -81,6 +84,9 @@ private static void setup( YamlDocConfig config, Properties props ) throws IOExc
8184
if ( StringUtils.isNotEmpty( useOpenapiTitle ) ) {
8285
config.setUseOpenapiTitle( BooleanUtils.isTrue( useOpenapiTitle ) );
8386
}
87+
if ( StringUtils.isNotEmpty( version ) ) {
88+
config.setVersion( Integer.parseInt( version ) );
89+
}
8490
}
8591

8692
private static void handleSingleMode( Properties props ) throws ConfigException {
@@ -129,6 +135,7 @@ private static void handleMultiMode( Properties props ) throws ConfigException {
129135
addIfNotEmpty(propsCurrent, YamlDocMain.ARG_EXCLUDE_PATHS, current.getExcludePaths() );
130136
addIfNotEmpty(propsCurrent, YamlDocMain.ARG_EXCLUDE_SCHEMAS, current.getExcludeSchemas() );
131137
addIfNotEmpty(propsCurrent, YamlDocMain.ARG_USE_OPENAPI_TITLE, current.getUseOpenapiTitle() );
138+
addIfNotEmpty(propsCurrent, YamlDocMain.ARG_VERSION, current.getVersion() );
132139
logger.info( "using parameters -> {}", props );
133140
YamlDocMain.worker( propsCurrent );
134141
}

src/main/java/org/fugerit/java/yaml/doc/config/OpenapiConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class OpenapiConfig extends BasicIdConfigType {
2424
private String excludeSchemas;
2525

2626
private String useOpenapiTitle;
27+
28+
private String version;
2729

2830
public String getInputYaml() {
2931
return inputYaml;
@@ -88,5 +90,13 @@ public String getUseOpenapiTitle() {
8890
public void setUseOpenapiTitle(String useOpenapiTitle) {
8991
this.useOpenapiTitle = useOpenapiTitle;
9092
}
93+
94+
public String getVersion() {
95+
return version;
96+
}
97+
98+
public void setVersion(String version) {
99+
this.version = version;
100+
}
91101

92102
}

src/main/resources/free_marker_yaml/yaml-doc-macro.ftl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<#macro printProperties propsMap labelMap>
1+
<#macro printAdditionalProperty currentFieldValue labelMap key><#if (currentFieldValue[key])??>, ${messageFormat(labelMap['label.'+key])}:${currentFieldValue[key]?string["#"]}</#if></#macro>
2+
3+
<#macro printAdditionalProperties currentFieldValue labelMap version><#if version &gt; 0 ><@printAdditionalProperty currentFieldValue=currentFieldValue labelMap=labelMap key='minLength'/><@printAdditionalProperty currentFieldValue=currentFieldValue labelMap=labelMap key='maxLength'/><@printAdditionalProperty currentFieldValue=currentFieldValue labelMap=labelMap key='minimum'/><@printAdditionalProperty currentFieldValue=currentFieldValue labelMap=labelMap key='maximum'/></#if></#macro>
4+
5+
<#macro printProperties propsMap labelMap version>
26
<row>
37
<cell header="true"><para style="bold">${messageFormat(labelMap['table.field.name'])}</para></cell>
48
<cell header="true"><para style="bold">${messageFormat(labelMap['table.field.type'])}</para></cell>
@@ -24,7 +28,7 @@
2428
<cell><para></para></cell>
2529
</#if>
2630
<cell><para>${printExample(currentFieldValue['example'])}</para></cell>
27-
<cell><para>${currentFieldValue['description']!''}<#if (currentFieldValue['deprecated']!false)> (${messageFormat(labelMap['table.field.deprecated'])})</#if></para></cell>
31+
<cell><para>${currentFieldValue['description']!''}<#if (currentFieldValue['deprecated']!false)> (${messageFormat(labelMap['table.field.deprecated'])})</#if><@printAdditionalProperties currentFieldValue=currentFieldValue labelMap=labelMap version=version/></para></cell>
2832
</row>
2933
</#list>
3034
</#macro>

src/main/resources/free_marker_yaml/yaml-doc-template.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<info name="doc-title">${messageFormat(labels['doc.def.title'])}</info>
2020
<info name="doc-author">${messageFormat(labels['doc.def.author'])}</info>
2121
<info name="doc-subject">${messageFormat(labels['doc.def.subject'])}</info>
22-
<info name="doc-creator">Fugerit - Yaml Doc Tool</info>
22+
<info name="doc-creator">Fugerit - Yaml Doc Tool (model version : ${yamlModel.config.version})</info>
2323
<info name="doc-language">${yamlModel.config.languageCode}</info>
2424

2525
<!-- specific properties for PDF -->
@@ -98,14 +98,14 @@
9898
<cell colspan="3"><para>${listAllOf['type']}</para></cell>
9999
</row>
100100
<#if (listAllOf['properties'])?? >
101-
<@docMacro.printProperties propsMap=listAllOf['properties'] labelMap=labels/>
101+
<@docMacro.printProperties propsMap=listAllOf['properties'] labelMap=labels version=yamlModel.config.version/>
102102
</#if>
103103
</#if>
104104
</#list>
105105

106106
</#if>
107107
<#if (currentSchemaValue['properties'])?? >
108-
<@docMacro.printProperties propsMap=currentSchemaValue['properties'] labelMap=labels/>
108+
<@docMacro.printProperties propsMap=currentSchemaValue['properties'] labelMap=labels version=yamlModel.config.version/>
109109
</#if>
110110
</table>
111111
</#list>

src/main/resources/lang/label.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ table.field.description=Description
1616
table.field.deprecated=Deprecated
1717

1818
type.extends=Extends
19-
type.base=Base type
19+
type.base=Base type
20+
21+
# data types labels https://swagger.io/docs/specification/data-models/data-types/
22+
label.minLength=Minimum length
23+
label.maxLength=Maximum length
24+
label.minimum=Minimum value
25+
label.maximum=Maximum value

src/main/resources/lang/label_it.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ table.field.description=Descrizione
1515
table.field.deprecated=Deprecato
1616

1717
type.extends=Estende
18-
type.base=Tipo base
18+
type.base=Tipo base
19+
20+
# data types labels https://swagger.io/docs/specification/data-models/data-types/
21+
label.minLength=Lunghezza minima
22+
label.maxLength=Lunghezza massima
23+
label.minimum=Valore minimo
24+
label.maximum=Valore massimo

0 commit comments

Comments
 (0)