Skip to content

HATEOAS still problematic #570

Closed
Closed
@valentinabojan

Description

@valentinabojan

There was a recent fix for HATEOAS support (#549), but the output is still problematic. The spring resource is outputting "albums", but the documentation is generating "additionalProperties" instead.

This is what we get:

// 20200415153822
// http://localhost:8080/v3/api-docs

{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "paths": {
    "/api/albums": {
      "get": {
        "tags": [
          "album-controller"
        ],
        "operationId": "getAllAlbums",
        "responses": {
          "200": {
            "description": "default response",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/PagedModelAlbum"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Album": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "releaseDate": {
            "type": "string"
          }
        }
      },
      "Links": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/Link"
        }
      },
      "PageMetadata": {
        "type": "object",
        "properties": {
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "totalElements": {
            "type": "integer",
            "format": "int64"
          },
          "totalPages": {
            "type": "integer",
            "format": "int64"
          },
          "number": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "PagedModelAlbum": {
        "type": "object",
        "properties": {
          "_embedded": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Album"
              }
            }
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "page": {
            "$ref": "#/components/schemas/PageMetadata"
          }
        }
      },
      "Link": {
        "$ref": "#/components/schemas/Link"
      }
    }
  }
}

This is what we expect:

// 20200415153535
// http://localhost:8080/v3/api-docs

{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "paths": {
    "/api/albums": {
      "get": {
        "tags": [
          "album-controller"
        ],
        "operationId": "getAllAlbums",
        "responses": {
          "200": {
            "description": "default response",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/PagedModelAlbum"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Album": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "releaseDate": {
            "type": "string"
          }
        }
      },
      "Links": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/Link"
        }
      },
      "PageMetadata": {
        "type": "object",
        "properties": {
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "totalElements": {
            "type": "integer",
            "format": "int64"
          },
          "totalPages": {
            "type": "integer",
            "format": "int64"
          },
          "number": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "PagedModelAlbum": {
        "type": "object",
        "properties": {
          "_embedded": {
            "type": "object",
            "properties": {
              "albums": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Album"
                }
              }
            }
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "page": {
            "$ref": "#/components/schemas/PageMetadata"
          }
        }
      },
      "Link": {
        "$ref": "#/components/schemas/Link"
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions