joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
http://www.jsonschema2pojo.org
Apache License 2.0
6.24k stars 1.66k forks source link

jsonschema2pojo not generating classes #1544

Closed kjellmoens closed 1 month ago

kjellmoens commented 1 year ago

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 commented 1 year ago

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

unkish commented 1 month ago

Closing issue based on comment above. Please feel free to reopen if the problem still exists.

Thank you