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

anyof allof oneof not support #1649

Open kspmmitt opened 4 days ago

kspmmitt commented 4 days ago

Hello, Can you please help to know what is the behavior is java class generation api if json schema has anyof/oneof/allof/not tags? Rgds, Kamal

unkish commented 3 days ago

Hi

At present these tags are ignored

kspmmitt commented 3 days ago

Property which uses anyof is generated with jave type as Object. It is not ignored as it is said above or?

Also till when support for these is expected, any tentative date?

unkish commented 3 days ago

Property which uses anyof is generated with jave type as Object.

Properties that use *Of will most likely be represented by Object as in:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "string_property": {
      "allOf": [{
          "properties": {
            "foo": {
              "type": "string"
            }
          },
          "required": ["foo"]
        }
      ]
    }
  }
}

Whilst following valid schema would not:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "allOf": [
    {
      "properties": {
        "foo": { "type": "string" }
      },
      "required": [ "foo" ]
    }
  ]
}

Also till when support for these is expected, any tentative date?

No tentative dates.

njimenezotto commented 2 days ago

Is there any workaround possible to take into account *Of by making a custom RuleFactory?

unkish commented 2 days ago

Is there any workaround possible to take into account *Of by making a custom RuleFactory?

Haven't tried all variants out though it could be, this really depends on the use-case(s).