Skip to content

[BUG] OpenAPI generation: properties alongside $refs are ignored #761

@atextor

Description

@atextor

How: List of performed steps
Generate an OpenAPI schema for an Aspect Model

What: Actual result vs expected result
Actual:
The schema will look something like this; where description properties are created from the samm:description of each samm:Property, and additionally $refs are added to the schemas corresponding to the Characteristic.

TestEntity:
  description: "Entity that has two Properties."
  x-samm-aspect-model-urn: "urn:samm:org.eclipse.esmf.test:1.0.0#TestEntity"
  type: object
  properties:
    myProperty1:
      description: "This is the myProperty1 description."
      x-samm-aspect-model-urn: "urn:samm:org.eclipse.esmf.test:1.0.0#myProperty1"
      $ref: "#/components/schemas/Text"
    myProperty2:
      description: "This is the myProperty2 description."
      x-samm-aspect-model-urn: "urn:samm:org.eclipse.esmf.test:1.0.0#myProperty2"
      $ref: "#/components/schemas/Text"
  required:
  - myProperty1
  - myProperty2

However, section 4.8.9.1 of the OpenAPI specification states that if both the defined object and the referenced object contain the same [property], the behaviour is undefined. In practice, tools handle this case differently: Redoc takes the description from the referenced schema, not the defined object. The swagger editor displayes a warning: "Sibling values alongside $refs are ignored". The schema generation must therefore be changed in a way ensures no properties are defined alongside a $ref.

Expected:
A schema is generated that does not include undefined behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedHas been viewed by one of the maintainers and is ready for further work, discussion or other steps.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions