Forum Discussion

StefanKern's avatar
StefanKern
Occasional Visitor
12 months ago

Circular definitions with oneOf and allOf

Hello Community,

 

we are having a openApi definition with a curcular reference with oneOf and allOf. Object Foo is defined to be of object Bar and object Bar is defined to be All of Bar.

 

 

"Foo" : {
        "properties" : {
          "createdBy" : {
            "format" : "int64",
            "type" : "integer",
            "readOnly" : true
          },
      	....
        "oneOf" : [ {
          "$ref" : "#/components/schemas/Bar"
        }, {
          "$ref" : "#/components/schemas/Baz"
        } ],

 

 

 

"Bar" : {
        ...
        "allOf" : [ {
          "$ref" : "#/components/schemas/Foo"
        } ],
      },

 

 

From all I can find in the documentation in oneOf, anyOf, allOf, not (swagger.io), this is a valid swagger file, however the outcome of the generator for angular-typescript is not compiling because it ignores the Bar properties, for Java it seems to ignore the Baz possibility.

 

Is this definition actually allowed?

 

Potential similar issue: https://community.smartbear.com/t5/Swagger-Open-Source-Tools/Circular-references-in-OpenAPI/td-p/229569

No RepliesBe the first to reply