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

Add openapi response definitions to approle/path_role.go #18198

Merged
merged 8 commits into from
Dec 5, 2022

Conversation

averche
Copy link
Contributor

@averche averche commented Dec 1, 2022

This PR modifies the path schema of approle/path_role.go, switching the old Callbacks to the equivalent Operations objects with a list of response fields for the 200 responses. This will allow us to generate a response structures in openapi.json. This PR is split out from #18055 along with #18192.

Example

For GET "/auth/approle/role/{role_name}/bind-secret-id" path, it will update the response as follows:

        "responses": {
          "200": {
            "description": "OK",
++            "content": {
++              "application/json": {
++                "schema": {
++                  "$ref": "#/components/schemas/ApproleRoleBindSecretIdResponse"
++                }
++             }
            }
          }
        }

And will add the actual response structure:

++      "ApproleRoleBindSecretIdResponse": {
++        "type": "object",
++        "properties": {
++          "bind_secret_id": {
++            "type": "boolean",
++            "description": "Impose secret_id to be presented when logging in using this role. Defaults to 'true'."
++          }
++        }
++      },

@averche averche marked this pull request as ready for review December 1, 2022 19:12
@averche averche requested review from lursu, dhuckins and AnPucel December 1, 2022 19:13
Copy link
Contributor

@dhuckins dhuckins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few questions but lgtm

builtin/credential/approle/path_role.go Show resolved Hide resolved
builtin/credential/approle/path_role.go Show resolved Hide resolved
Comment on lines 265 to 266
Callback: b.pathRoleDelete,
Responses: responseOK,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this returns nil, nil


would the response be "ok" (200) or would it return 204 response code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it is returned as 204 for all nil, _ responses. Let me update it. Good catch 👍

Copy link
Contributor

@AnPucel AnPucel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had looked over most of it in your previous PR and I gave it another check and lgtm

Copy link
Collaborator

@lursu lursu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from response-structures-openapi to main December 5, 2022 16:11
@averche averche merged commit 5db121b into main Dec 5, 2022
AnPucel pushed a commit that referenced this pull request Jan 14, 2023
This PR modifies the path schema of `approle/path_role.go`, switching the old `Callbacks` to the equivalent `Operations` objects with a list of response fields for the 200 responses. This will allow us to generate a response structures in openapi.json. This PR is split out from #18055 along with #18192.

### Example

For `GET "/auth/approle/role/{role_name}/bind-secret-id"` path, it will update the response as follows:

```diff
        "responses": {
          "200": {
            "description": "OK",
++            "content": {
++              "application/json": {
++                "schema": {
++                  "$ref": "#/components/schemas/ApproleRoleBindSecretIdResponse"
++                }
++             }
            }
          }
        }
```

And will add the actual response structure:

```diff
++      "ApproleRoleBindSecretIdResponse": {
++        "type": "object",
++        "properties": {
++          "bind_secret_id": {
++            "type": "boolean",
++            "description": "Impose secret_id to be presented when logging in using this role. Defaults to 'true'."
++          }
++        }
++      },
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants