Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonschema2pojo not generating classes #1544

Open
kjellmoens opened this issue Jul 18, 2023 · 1 comment
Open

jsonschema2pojo not generating classes #1544

kjellmoens opened this issue Jul 18, 2023 · 1 comment

Comments

@kjellmoens
Copy link

kjellmoens commented Jul 18, 2023

I am trying to generate pojo from a json schema but the classes are not generated.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "changeRealizationDate": {
      "type": "string",
      "format": "date-time"
    },
    "destinationEmployerId": {
      "$ref": "#/definitions/EmployerId"
    },
    "modificationType": {
      "type": "string",
      "pattern": "^\\d{2}$"
    },
    "originalEmployerId": {
      "$ref": "#/definitions/EmployerId"
    }
  },
  "required": [
    "changeRealizationDate",
    "destinationEmployerId",
    "modificationType",
    "originalEmployerId"
  ],
  "definitions": {
    "EmployerId": {
      "description": "Definitive or provisional NSSO number, assigned to each registered employer or local or provincial administration.",
      "type": "integer",
      "format": "int64",
      "minimum": 197,
      "maximum": 5999999999
    }
  }
}

Contents of the pom.xml

            <plugin>
                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
                    <outputDirectory>${basedir}/directory/src/main/java</outputDirectory>
                    <includeJsr303Annotations>true</includeJsr303Annotations>
                    <dateType>java.time.LocalDate</dateType>
                    <dateTimeType>java.time.LocalDateTime</dateTimeType>
                    <generateBuilders>true</generateBuilders>
                    <targetPackage>be.smals.nnsoregistrationnumber_transfer_event_generator.dto</targetPackage>
                    <includeAdditionalProperties>false</includeAdditionalProperties>
                    <targetVersion>1.8</targetVersion>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

When I run maven with the -X option, I get the following output but no files are generated

[DEBUG] Reading schema: file:/C:/Users/kjm/Source/dimona-transfer-event-generator/src/main/resources/schema/payload.schema.json
[DEBUG] Adding be.smals.nnsoregistrationnumber_transfer_event_generator.dto.PayloadSchema
@unkish
Copy link
Collaborator

unkish commented Jul 21, 2023

Hi

Schema looks correct, I have tried it out and output was generated as expected.
Did you check correct folder for output: C:/Users/kjm/Source/dimona-transfer-event-generator/directory/src/main/java ?

The only thing I would change is removing:
<outputDirectory>${basedir}/directory/src/main/java</outputDirectory>
Such that output would be generated under: /target/generated-sources/jsonschema2pojo/be/smals/nnsoregistrationnumber_transfer_event_generator and automatically picked up by IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants