Skip to content

Commit

Permalink
FIxing "string schema cannot be cast to array schema" (#84)
Browse files Browse the repository at this point in the history
* Fixed: StringSchema cannot be cast to class ArraySchema

* Minor version update in pom.xml

* Version update in README.md

* Update java Version

---------

Co-authored-by: Jose E. Garcia Maciñeiras <[email protected]>
Co-authored-by: José Enrique García Maciñeiras <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent d265456 commit b279f55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: "11"
java-version: "17"
distribution: "adopt"
- name: Build with Maven
run: mvn -B package --file pom.xml
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</licenses>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven-plugin-plugin.version>3.6.0</maven-plugin-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.3.2</maven-javadoc-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,11 @@ private List<Pair<Body, BodyMatchers>> createBodyForProperty(final String ref, f
final Schema<?> subSchema = getSchemaFromComponent(subRef);
if (Objects.nonNull(subSchema.getProperties())) {
bodyList = applyMapToBodyList(propertyBodyList, property.getKey(), processComplexBodyAndMatchers(property.getKey(), subSchema.getProperties()));
} else if (subSchema.getItems() instanceof ComposedSchema) {
final Schema<?> arraySchema = subSchema.getItems();
} else if (subSchema instanceof ArraySchema && ((ArraySchema) subSchema).getItems() instanceof ComposedSchema) {
final Schema<?> arraySchema = ((ArraySchema) subSchema).getItems();
bodyList = applyBodyToList(propertyBodyList, property.getKey(), processComposedSchema((ComposedSchema) arraySchema));
} else {
final Schema<?> arraySchema = subSchema.getItems();
bodyList = this.applyObjectToBodyList(propertyBodyList, ref, writeBodyMatcher(null, ref, arraySchema, arraySchema.getType()));
bodyList = this.applyObjectToBodyList(propertyBodyList, ref, writeBodyMatcher(null, ref, subSchema, subSchema.getType()));
}
} else if (Objects.nonNull(property.getValue().getEnum())) {
bodyList = this.applyObjectToBodyList(propertyBodyList, property.getKey(), writeBodyMatcher(null, property.getKey(), property.getValue(), BasicTypeConstants.ENUM));
Expand Down

0 comments on commit b279f55

Please sign in to comment.