Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Error on generate api #72

Open
m33ch opened this issue Nov 28, 2015 · 3 comments
Open

Error on generate api #72

m33ch opened this issue Nov 28, 2015 · 3 comments
Labels

Comments

@m33ch
Copy link

m33ch commented Nov 28, 2015

Hi,

thank you for this package.

I got an error when i try to generate a php api. This is error

panic: interface conversion: interface is nil, not map[string]interface {}

goroutine 1 [running]:
runtime.panic(0x6ff260, 0xc210086dc0)
    /usr/local/lib/gvm/gos/go1.2/src/pkg/runtime/panic.c:266 +0xb6
github.com/pksunkara/alpaca/alpaca.WritePhp(0xc2100b1b40)
    /usr/local/lib/gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/langs_php.go:37 +0x535
github.com/pksunkara/alpaca/alpaca.WriteLibraries(0xc21000a938)
    /usr/local/lib/gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/alpaca.go:66 +0x88
main.main()
    /usr/local/lib/gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/main.go:52 +0x21a

goroutine 5 [finalizer wait]:
runtime.park(0x40adc0, 0xaf4450, 0xaf1c68)
    /usr/local/lib/gvm/gos/go1.2/src/pkg/runtime/proc.c:1342 +0x66
runfinq()
    /usr/local/lib/gvm/gos/go1.2/src/pkg/runtime/mgc0.c:2276 +0x84
runtime.goexit()
    /usr/local/lib/gvm/gos/go1.2/src/pkg/runtime/proc.c:1394

Thank you

@pksunkara
Copy link
Owner

Hey @m33ch, Unfortunately, you are missing something in the doc.json which is being incompatible with the api.json. I am planning to improve the error handling though.

@m33ch
Copy link
Author

m33ch commented Dec 11, 2015

Hi @pksunkara,

thank you for your reply.

This is my api.json

{
    "base":"http://local.dev",
    "version":"1",
    "authorization":{
        "need_auth":true,
        "header":true
    },
    "request":{
        "formats":{
            "default":"json",
            "form":false,
            "json":true
        }
    },
    "response":{
        "formats":{
            "default":"json",
            "json":true
        },
        "suffix":true
    },
    "error":{
        "message":"error"
    },
    "classes":[
        {
            "name":"discounts",
            "args":[
                "id"
            ],
            "functions":[
                {
                    "name":"index",
                    "method":"get",
                    "path":"/discounts"
                },
                {
                    "name":"show",
                    "method":"get",
                    "path":"/discounts/:id"
                },
                {
                    "name":"store",
                    "path":"/discounts/",
                    "method":"post",
                    "params":[
                        {
                            "name":"name",
                            "required":true
                        },
                        {
                            "name":"value"
                        },
                        {
                            "name":"value_type"
                        },
                        {
                            "name":"status"
                        }
                    ]
                },
                {
                    "name":"update",
                    "path":"/discounts/:id",
                    "method":"post",
                    "params":[
                        {
                            "name":"name",
                            "required":true
                        },
                        {
                            "name":"value"
                        },
                        {
                            "name":"value_type"
                        },
                        {
                            "name":"status"
                        }
                    ]
                },
                {
                    "name":"destroy",
                    "method":"delete",
                    "path":"/discounts/:id"
                }
            ]
        }
    ]
}

And this is doc.json

{
    "discounts":{
        "title":"Discount",
        "desc":"Returns discount api instance",
        "args":{
            "id":{
                "desc":"Id of discount",
                "value":"1"
            }
        },
        "functions" : {
            "index":{
                "title":"Get user discounts",
                "desc":"Retrieve created user discounts"
            },
            "store":{
                "title":"Create new discount",
                "desc":"Create new discount",
                "params":{
                    "name":{
                        "desc":"Name on discount",
                        "value":"Sold Out 50%!"
                    },
                    "value":{
                        "desc":"Value of discount",
                        "value":"20"
                    },
                    "value_type":{
                        "desc":"Type of discount : absolute or percentage",
                        "value":"absolute"
                    },
                    "status":{
                        "desc":"Active discount? (enabled, disabled)",
                        "value":"disabled"
                    }
                }
            },
            "show":{
                "title":"Get a user discount",
                "desc":"Retrieve one discount"
            },
            "destroy":{
                "title":"Delete a user discount",
                "desc":"Delete one discount"
            }
        }
    }
}

That json files are created based on your example.

Thank you very much!

@JadedEvan
Copy link

Also having this same issue with both of the examples provided in this repo.

alpaca ~/alpaca/examples/helpful/
panic: interface conversion: interface is nil, not map[string]interface {}

goroutine 1 [running]:
runtime.panic(0x6ff260, 0xc2100bcac0)
        /usr/local/lib/gvm/gos/go1.2/src/pkg/runtime/panic.c:266 +0xb6

@pksunkara pksunkara added the bug label May 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants