openapi-cli-generator icon indicating copy to clipboard operation
openapi-cli-generator copied to clipboard

How to setup the credentials file?

Open myrho opened this issue 5 years ago • 0 comments

Hello, I can't figure out how to setup a credentials file. I'm a complete go newbie. This is my main.go:

package main

import (
    "github.com/danielgtaylor/openapi-cli-generator/cli"
    "github.com/danielgtaylor/openapi-cli-generator/apikey"
)

func main() {
	cli.Init(&cli.Config{
		AppName:   "example",
		EnvPrefix: "EXAMPLE",
		Version:   "1.0.0",
	})

  exampleRegister(false)
  apikey.Init("Authorization", apikey.LocationHeader)

   cli.Creds.Set("profiles.default.api_key", "mykey")
   
   cli.Root.Execute()
}

This works, but the api key is hardcorded. Where and how should I define the key in the credentials file? I've tried:

./.example/config.json:

{ "example":
    { "profiles":
        { "default":
            { "api_key": "mykey"
            }
        }
    }
}

Any help is appreciated!

myrho avatar Nov 15 '20 01:11 myrho