Skip to content

Api with @Operation on @RepositoryRestController are not registered #1053

Closed
@speralta

Description

@speralta

Describe the bug
Using spring-data-rest, we need to use specific controllers annotated with @RepositoryRestController to define some API. Methods in those specific controllers are not added to generated documentation.

I try to add @Operation on method as recommended on issue #263 unsuccesfully.
Not sure if it's a bug or if I'm missing something.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    2.4.2
  • What modules and versions of springdoc-openapi are you using?
    1.5.3
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    Actual :
  "openapi": "3.0.1",
  "info": {
    "title": "Test API",
    "description": "Endpoints documentation",
    "version": "0.0.1"
  },
  "servers": [
    {
      "url": "http://localhost:8080/",
      "description": "Generated server url"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/domains": {
      "get": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "get-domain",
        "operationId": "getCollectionResource-domain-get_1",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Zero-based page index (0..N)",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "size",
            "in": "query",
            "description": "The size of the page to be returned",
            "required": false,
            "schema": {
              "minimum": 1,
              "type": "integer",
              "default": 20
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionModelDomain"
                }
              },
              "application/x-spring-data-compact+json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionModelDomain"
                }
              },
              "text/uri-list": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionModelDomain"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "create-domain",
        "operationId": "postCollectionResource-domain-post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Domain"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/RepresentationModelDomain"
                }
              }
            }
          }
        }
      }
    },
    "/domains/{id}": {
      "get": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "get-domain",
        "operationId": "getItemResource-domain-get",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityModelDomain"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "put": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "update-domain",
        "operationId": "putItemResource-domain-put",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Domain"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/RepresentationModelDomain"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/RepresentationModelDomain"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          }
        }
      },
      "delete": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "delete-domain",
        "operationId": "deleteItemResource-domain-delete",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "patch": {
        "tags": [
          "domain-entity-controller"
        ],
        "description": "patch-domain",
        "operationId": "patchItemResource-domain-patch",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Domain"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/RepresentationModelDomain"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          }
        }
      }
    },
    "/profile": {
      "get": {
        "tags": [
          "profile-controller"
        ],
        "operationId": "listAllFormsOfMetadata",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/RepresentationModelObject"
                }
              }
            }
          }
        }
      }
    },
    "/profile/domains": {
      "get": {
        "tags": [
          "profile-controller"
        ],
        "operationId": "descriptor_1",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string"
                }
              },
              "application/alps+json": {
                "schema": {
                  "type": "string"
                }
              },
              "application/schema+json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonSchema"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AbstractJsonSchemaPropertyObject": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "readOnly": {
            "type": "boolean"
          }
        }
      },
      "Item": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "properties": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject"
            }
          },
          "requiredProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "JsonSchema": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "properties": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject"
            }
          },
          "requiredProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "definitions": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/Item"
            }
          },
          "type": {
            "type": "string"
          },
          "$schema": {
            "type": "string"
          }
        }
      },
      "Links": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/Link"
        }
      },
      "RepresentationModelObject": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        }
      },
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "field": {
            "type": "string"
          }
        }
      },
      "RepresentationModelDomain": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        }
      },
      "EntityModelDomain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "field": {
            "type": "string"
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        }
      },
      "CollectionModelDomain": {
        "type": "object",
        "properties": {
          "_embedded": {
            "type": "object",
            "properties": {
              "domains": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        }
      },
      "Link": {
        "type": "object",
        "properties": {
          "href": {
            "type": "string"
          },
          "hreflang": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "deprecation": {
            "type": "string"
          },
          "profile": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "templated": {
            "type": "boolean"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "UUID"
      }
    }
  }
}

Expected behavior

  • A clear and concise description of what you expected to happen.
    A new PathItem corresponding to "/domain/test".
  • What is the expected result using OpenAPI Description (yml or json)?
...
  "/domains/test": {
      "get": {
        "operationId": "test-get",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityModelDomain"
                }
              }
            }
          }
        }
      },
      ...

Additional context
The springdoc-openapi-data-rest registers the @RepositoryRestResource without issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions