Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ jobs:
- checkout
- command_docker_build_and_test:
jobId: "testPythonClientSamples"
testJava17ClientSamples:
docker:
- image: cimg/openjdk:17.0.9
working_directory: ~/OpenAPITools/openapi-json-schema-generator
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
steps:
- command_build_and_test:
jobId: "testJava17ClientSamples"
workflows:
version: 2
build:
Expand All @@ -154,3 +165,4 @@ workflows:
- mvnCleanInstall
- testPython38ClientSamples
- testPython39ClientSamples
- testJava17ClientSamples
7 changes: 7 additions & 0 deletions .circleci/parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ elif [ "$JOB_ID" = "testPythonClientSamples" ]; then
(cd samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python && make test)
(cd samples/client/openapi_features/security/python && make test)

elif [ "$JOB_ID" = "testJava17ClientSamples" ]; then
echo "Running job $JOB_ID ..."
java -version

(cd samples/client/petstore/java && mvn test)
(cd samples/client/3_0_3_unit_test/java && mvn test)

else
echo "Running job $JOB_ID"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java
src/main/java/org/openapijsonschematools/schemas/validation/KeywordEntry.java
src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/LengthValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxItemsValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxLengthValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxPropertiesValidator.java
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java
src/main/java/org/openapijsonschematools/schemas/validation/KeywordEntry.java
src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/LengthValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxItemsValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxLengthValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MaxPropertiesValidator.java
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/java/docs/components/schemas/Apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^[A-Z\s]*$",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE,<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^[A-Z\\s]*$",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand All @@ -75,7 +75,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^[a-zA-Z\s]*$"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^[a-zA-Z\\s]*$"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ A string starting with &#x27;image_&#x27; (case insensitive) and one to three di
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^image_\d{1,3}$",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE,<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^image_\\d{1,3}$",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand All @@ -143,7 +143,7 @@ A string that is a 10 digit number. Can have leading zeros.
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^\d{10}$"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^\\d{10}$"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down Expand Up @@ -225,7 +225,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"[a-z]",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE,<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"[a-z]",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ None
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"[a-z]",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE,<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"[a-z]",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pattern.CASE_INSENSITIVE<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class Cultivar extends JsonSchema {
String.class
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"^[a-zA-Z\s]*$"
"^[a-zA-Z\\s]*$"
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand All @@ -39,8 +39,8 @@ public static class Origin extends JsonSchema {
String.class
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"^[A-Z\s]*$",
Pattern.CASE_INSENSITIVE,
"^[A-Z\\s]*$",
Pattern.CASE_INSENSITIVE
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static class StringSchema extends JsonSchema {
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"[a-z]",
Pattern.CASE_INSENSITIVE,
Pattern.CASE_INSENSITIVE
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static class PatternWithDigits extends JsonSchema {
String.class
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"^\d{10}$"
"^\\d{10}$"
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand All @@ -269,8 +269,8 @@ public static class PatternWithDigitsAndDelimiter extends JsonSchema {
String.class
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"^image_\d{1,3}$",
Pattern.CASE_INSENSITIVE,
"^image_\\d{1,3}$",
Pattern.CASE_INSENSITIVE
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static class StringSchema extends JsonSchema {
))),
new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"[a-z]",
Pattern.CASE_INSENSITIVE,
Pattern.CASE_INSENSITIVE
)))
));
public static String validate(String arg, SchemaConfiguration configuration) throws ValidationException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.openapijsonschematools.schemas.validation;

import java.text.BreakIterator;

public abstract class LengthValidator {
protected int getLength(String text) {
int graphemeCount = 0;
BreakIterator graphemeCounter = BreakIterator
.getCharacterInstance();
graphemeCounter.setText(text);
while (graphemeCounter.next() != BreakIterator.DONE) {
graphemeCount++;
}
return graphemeCount;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void processOpts() {
keywordValidatorFiles.add("JsonSchema");
keywordValidatorFiles.add("KeywordEntry");
keywordValidatorFiles.add("KeywordValidator");
schemaSupportingFiles.add("LengthValidator");
keywordValidatorFiles.add("LengthValidator");
keywordValidatorFiles.add("MaximumValidator");
keywordValidatorFiles.add("MaxItemsValidator");
keywordValidatorFiles.add("MaxLengthValidator");
Expand Down Expand Up @@ -1845,7 +1845,8 @@ public CodegenPatternInfo getPatternInfo(String pattern) {
if (pattern == null) {
return null;
}
Matcher m = patternRegex.matcher(pattern);
String usedPattern = handleSpecialCharacters(pattern);
Matcher m = patternRegex.matcher(usedPattern);
if (m.find()) {
int groupCount = m.groupCount();
if (groupCount == 1) {
Expand All @@ -1866,6 +1867,6 @@ public CodegenPatternInfo getPatternInfo(String pattern) {
return new CodegenPatternInfo(isolatedPattern, flags);
}
}
return new CodegenPatternInfo(pattern, null);
return new CodegenPatternInfo(usedPattern, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"{{{pattern}}}"{{#if flags}},{{/if}}<br>
{{~#if flags}}
{{#eq flags.size 1}}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{#each flags}}Pattern.{{#eq this "i"}}CASE_INSENSITIVE{{/eq}}{{#eq this "m"}}MULTILINE{{/eq}}{{#eq this "s"}}DOTALL{{/eq}}{{#eq this "u"}}UNICODE_CHARACTER_CLASS{{/eq}}{{/each}},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{#each flags}}Pattern.{{#eq this "i"}}CASE_INSENSITIVE{{/eq}}{{#eq this "m"}}MULTILINE{{/eq}}{{#eq this "s"}}DOTALL{{/eq}}{{#eq this "u"}}UNICODE_CHARACTER_CLASS{{/eq}}{{/each}}<br>
{{~else}}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
{{~#each flags}}
Expand Down Expand Up @@ -32,7 +32,7 @@ new KeywordEntry("pattern", new PatternValidator(Pattern.compile(
"{{{pattern}}}"{{#if flags}},{{/if}}
{{#if flags}}
{{#eq flags.size 1}}
{{#each flags}}Pattern.{{#eq this "i"}}CASE_INSENSITIVE{{/eq}}{{#eq this "m"}}MULTILINE{{/eq}}{{#eq this "s"}}DOTALL{{/eq}}{{#eq this "u"}}UNICODE_CHARACTER_CLASS{{/eq}}{{/each}},
{{#each flags}}Pattern.{{#eq this "i"}}CASE_INSENSITIVE{{/eq}}{{#eq this "m"}}MULTILINE{{/eq}}{{#eq this "s"}}DOTALL{{/eq}}{{#eq this "u"}}UNICODE_CHARACTER_CLASS{{/eq}}{{/each}}
{{else}}
(
{{#each flags}}
Expand Down