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 mount path into the default generated openapi.json spec (UI) #17926

Merged
merged 12 commits into from
Dec 8, 2022

Conversation

averche
Copy link
Contributor

@averche averche commented Nov 14, 2022

The current behaviour is to only add mount paths into the generated opeanpi.json spec if a generic_mount_paths flag is added to the request. This means that we would have to maintain two different openapi.json files, which is not ideal. The new solution in this PR is to add {<mount>_mount_path} into every path with a default value specified:

--    "/auth/token/accessors/": {
++    "/auth/{token_mount_path}/accessors/": {
      "parameters": [
++        {
++          "name": "token_mount_path",
++          "description": "....",
++          "in": "path",
++          "schema": {
++            "type": "string",
++          "default": "token"
++          }
++        }
...
     ],

Additionally, fixed the logic to generate the operationId (used to generate method names in the code generated from OpenAPI spec). It had a bug where the ID had mountPath in it.

const pathInfo = help.openapi.paths[path];
const params = pathInfo.parameters;
const paramProp = {};

// include url params
if (params) {
const { name, schema, description } = params[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the crux of the change that fixes the UI issues. Before, we only cared about the first param for the path. Now that the backend mount path is also a path param, we instead iterate over all the path params, throw out _mount_path (because we already capture it as backend) and add the rest to the model

@@ -295,7 +299,8 @@ export default Service.extend({
},

registerNewModelWithProps(helpUrl, backend, newModel, modelName) {
return this.getProps(helpUrl, backend).then((props) => {
const pathName = modelName === 'model:generated-user-userpass' ? '/users/{username}' : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

This might not actually be needed, checking now

@averche averche marked this pull request as ready for review December 7, 2022 16:25
@averche
Copy link
Contributor Author

averche commented Dec 7, 2022

Thank you for fixing the UI parts, @chelshaw!

@averche averche requested review from lursu, AnPucel and dhuckins December 7, 2022 16:26
sdk/framework/openapi.go Show resolved Hide resolved
maxb added a commit to maxb/vault that referenced this pull request Dec 27, 2022
PR hashicorp#17926 already deleted the implementation of the
`generic_mount_paths` field so it needs to be removed from the declared
fields of the path too, so help and OpenAPI isn't misleading.
averche pushed a commit that referenced this pull request Jan 4, 2023
PR #17926 already deleted the implementation of the
`generic_mount_paths` field so it needs to be removed from the declared
fields of the path too, so help and OpenAPI isn't misleading.
averche added a commit that referenced this pull request Jan 6, 2023
averche added a commit that referenced this pull request Jan 10, 2023
…17926)" (#18617)

* Revert "Add mount path into the default generated openapi.json spec (UI) (#17926)"

This reverts commit db8efac.

* Revert "Remove `generic_mount_paths` field (#18558)"

This reverts commit 79c8f62.
AnPucel pushed a commit that referenced this pull request Jan 14, 2023
PR #17926 already deleted the implementation of the
`generic_mount_paths` field so it needs to be removed from the declared
fields of the path too, so help and OpenAPI isn't misleading.
AnPucel pushed a commit that referenced this pull request Jan 14, 2023
…17926)" (#18617)

* Revert "Add mount path into the default generated openapi.json spec (UI) (#17926)"

This reverts commit db8efac.

* Revert "Remove `generic_mount_paths` field (#18558)"

This reverts commit 79c8f62.
AnPucel pushed a commit that referenced this pull request Feb 3, 2023
PR #17926 already deleted the implementation of the
`generic_mount_paths` field so it needs to be removed from the declared
fields of the path too, so help and OpenAPI isn't misleading.
AnPucel pushed a commit that referenced this pull request Feb 3, 2023
…17926)" (#18617)

* Revert "Add mount path into the default generated openapi.json spec (UI) (#17926)"

This reverts commit db8efac.

* Revert "Remove `generic_mount_paths` field (#18558)"

This reverts commit 79c8f62.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants