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

[Schema] Inline description and vendor extensions under allOf is not recognized #1125

Closed
chenliu0831 opened this issue Sep 27, 2018 · 5 comments

Comments

@chenliu0831
Copy link

Description

We have an use-case where description and vendor extensions are put inside allOf as inline schema. However those inlined fields went missing from the input to the generator as well as the final generated code. See below:

ModelA:
  allOf:
    - "$ref": "#/components/schemas/ModelBase"
    - type: object
      description: foo
      properties:
        value:
          type: integer
          description: TODO
      x-model-version: '1.0'
      x-model-module: model.base
  x-model-base: model.base.ModelBase@1.0

Debug output run with -DdebugModels which should be the same to any generators. Notice how top level x-model-base is getting picked up in vendorExtensions while the extensions are not.

"model" : {
    "parent" : "ModelBase",
    "parentSchema" : "ModelBase",
    "interfaces" : [ "ModelBase" ],
    "name" : "ModelA",
    "classname" : "ModelA",
    "classVarName" : "ModelA",
    "modelJson" : "{\n  \"allOf\" : [ {\n    \"$ref\" : \"#/components/schemas/ModelBase\"\n  }, {\n    \"type\" : \"object\",\n    \"properties\" : {\n      \"value\" : {\n        \"type\" : \"integer\",\n        \"description\" : \"TODO\",\n        \"format\" : \"int32\"\n      }\n    },\n    \"description\" : \"foo\",\n    \"x-model-version\" : \"1.0\",\n    \"x-model-module\" : \"model.base\"\n  } ],\n  \"x-model-base\" : \"model.base.ModelBase@1.0\"\n}",
    "classFilename" : "ModelA",
    "isAlias" : false,
    "isString" : false,
    "isInteger" : false,
    "vars" : [],
    "requiredVars" : [],
    "optionalVars" : [],
    "readOnlyVars" : [],
    "readWriteVars" : [],
    "allVars" : [],
    "parentVars" : [ ],
    "mandatory" : [ ],
    "allMandatory" : [ ],
    "imports" : [ "AttributeMetadata", "ModelBase" ],
    "hasVars" : true,
    "emptyVars" : false,
    "hasMoreModels" : false,
    "hasEnums" : false,
    "isEnum" : false,
    "hasRequired" : false,
    "hasOptional" : true,
    "isArrayModel" : false,
    "hasChildren" : false,
    "isMapModel" : false,
    "hasOnlyReadOnly" : false,
    "vendorExtensions" : {
      "x-model-base" : "model.base.ModelBase@1.0"
    }
  }
}

According to the schema object spec, either way seems to be valid. Is this a bug, a feature by design or I misunderstand anything?

Thanks.

openapi-generator version

3.3.2, also happens with master.

@chenliu0831
Copy link
Author

Could someone take a look? Thanks!

@wing328
Copy link
Member

wing328 commented Nov 1, 2018

@chenliu0831 thanks for reporting the issue. I've filed #1360 with better allOf support. I don't think it addresses the issue you reported but still would appreciate your feedback on the PR.

@chenliu0831
Copy link
Author

@wing328 Great to see you working on this! A small suggestion for your PR #1360: could you add a few high level pointers to the module where we could look at the major change of those fixes/features. It's somewhat hard to follow for someone not familiar with the repository. Thanks!

@wing328
Copy link
Member

wing328 commented Dec 10, 2018

@chenliu0831 #1360 has been merged into master. Please give it a try and let us know if you still see issues with allOf

@wing328
Copy link
Member

wing328 commented Dec 10, 2018

could you add a few high level pointers to the module where we could look at the major change of those fixes/features.

Agree. I'll try to add more comments to the code so that new users can more easily follow.

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

No branches or pull requests

2 participants