Skip to content

Spring DATA Rest OneToMany/ManyToOne/OneToOne associations are absent in OpenAPI model #1773

Closed
@valb3r

Description

@valb3r

Describe the bug
OneToMany/ManyToOne associations are missing in the generated model

To Reproduce

Screenshot 2022-08-01 at 20 20 51

Observed YAML:

EntityModelProductItem:
      required:
      - locationInWarehouse
      type: object
      properties:
        quantity:
          type: integer
          format: int64
        locationInWarehouse:
          type: string
        _links:
          $ref: '#/components/schemas/Links'

Expected behavior

  • Expected having relations in all models
  • What is the expected result using OpenAPI Description (yml or json)?
    Expected YAML:
EntityModelProductItem:
      required:
      - locationInWarehouse
      type: object
      properties:
        quantity:
          type: integer
          format: int64
        product:
           $ref: '#/components/schemas/EntityModelProduct'
        locationInWarehouse:
          type: string
        _links:
          $ref: '#/components/schemas/Links'

It would be very helpful if it was possible to include associations everywhere (in GET /entities/id, GET /entities ....) as relationships can be exposed via Excerpts, but currently generated YAML is not usable due to missing relationships references in spec

Currently, desired result is achievable from RepositoryRestConfigurer:

@Component
public class ExposeIdConfiguration implements RepositoryRestConfigurer {

    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
        config.exposeIdsFor(Product.class, ProductItem.class);
    }
}

But IDs exposure and entity content seem to be different concepts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions