jsonschema2pojo icon indicating copy to clipboard operation
jsonschema2pojo copied to clipboard

anyof allof oneof not support

Open kspmmitt opened this issue 1 year ago • 5 comments

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

kspmmitt avatar Nov 25 '24 03:11 kspmmitt

Hi

At present these tags are ignored

unkish avatar Nov 25 '24 13:11 unkish

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?

kspmmitt avatar Nov 26 '24 04:11 kspmmitt

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.

unkish avatar Nov 26 '24 07:11 unkish

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

njimenezotto avatar Nov 26 '24 13:11 njimenezotto

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).

unkish avatar Nov 26 '24 17:11 unkish