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

API Token from use_value is included in generated Postman collection #701

Closed
1 task done
Grldk opened this issue Jul 25, 2023 · 1 comment
Closed
1 task done

API Token from use_value is included in generated Postman collection #701

Grldk opened this issue Jul 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Grldk
Copy link

Grldk commented Jul 25, 2023

Scribe version

4.22.0

PHP version

8.1.18

Framework

Laravel

Framework version

10.15.0

Scribe config

routes.apply.response_calls.methods => ['GET','POST']
routes.apply.response_calls.config.app.env => 'testing'
auth.enabled => true
auth.default => true
auth.name => "Authorization"
auth.use_value => "actual_api_token"
examples.models_source => removed factoryCreate

What happened?

Just started using this package, like it so far, so thanks very much for your work!

Ran into the following, not sure if this is something I did wrong, but from reading the docs and the config file I think this shouldnt happen:

I've started to get this to work on one of our API endpoints, which is a POST endpoint. I've added some @bodyParam docs in the Request class, added the following to the AppServiceProvider:

        if (class_exists(Scribe::class)) {
            Scribe::bootstrap(function (GenerateDocumentation $command) {
                App::setLocale('en');
            });

            Scribe::instantiateFormRequestUsing(function (string $form_request_class_name) {
                if ($form_request_class_name === {{className}}::class) {
                    return request()->createFrom(request(), new {{className}}(resolve({{dependency}}::class)));
                }
            });
        }

This has resulted in a Postman collection json file which includes the following:

    "auth": {
        "type": "bearer",
        "bearer": [
            {
                "key": "Authorization",
                "value": "actual_api_token",
                "type": "string"
            }
        ]
    }

Although the config explicitly says the following:

        /*
         * The value of the parameter to be used by Scribe to authenticate response calls.
         * This will NOT be included in the generated documentation.
         * If this value is empty, Scribe will use a random value.
         */

So I was not expecting to see the actual api token in put in the config to show up in the Postman collection. Is this a bug, or did I misunderstand something?

Docs

@Grldk Grldk added bug Something isn't working triage labels Jul 25, 2023
@shalvah shalvah removed the triage label Jul 25, 2023
@shalvah
Copy link
Contributor

shalvah commented Jul 25, 2023

Oof, definitely a bug, probably copy and paste, as we don't do that for other auth method, only bearer tokens.

'value' => $this->config->get('auth.use_value'),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants