apicollective / apibuilder

Simple, Comprehensive Tooling for Modern APIs
https://www.apibuilder.io/
MIT License
563 stars 83 forks source link

Add Generator functionality bugs #368

Closed mchimirev closed 8 years ago

mchimirev commented 9 years ago

For reference, this is where my generators are running. Just java generator for now, but we'll be serving an Android one and IOS/Swift one from this endpoint.

Although my generator is not implemented in a standard way, from what I understand, generators should be able to run any where as long as they serve correct JSON. My generator, for example uses AWS Gateway + AWS Lambda, which then wraps api-generator library. This allows us to not to have to run an instance all the time just to serve a generator.

https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod/generators?offset=0&limit=10

  1. When I made an attempt to add a generator I got a 500, it didn't like my format, but it seems that it put an entry in the database. So next time I tried adding the same generator I got a database duplicate key error (didn't save the key name, sorry)
  2. After adding generators under my account, my generator is seemingly available for every one. Also, I cannot remove it, or change any properties on it, so now generator "java_models_via_mobile_lambda" is stuck up there
  3. When my generator is invoked, I get a 500 with no explanation to what went wrong. Presumably, my generator is not returning what apidoc is expecting, but it would be nice to get some kind of error message. http://apidoc.me/gilt/checkout-api/0.1.50/java_models_via_mobile_lambda
Seanstoppable commented 9 years ago

That setup sounds neat!

Curling the invocations endpoint (https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/invocations/java_models_via_mobile_lambda), I get a "403 Forbidden" return code, and I was also able to make a local copy of apidoc spit out that error code. That makes me think that the generator is not actually receiving requests.

mchimirev commented 9 years ago
  1. I'm expecting the call on https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod/java_models_via_mobile_lambda (/prod/ instead of /invocations/). Maybe that's wrong. /prod/ is part of the apidoc gateway setup, so maybe URL should have /prod/invocations/ in it?
  2. It's a POST, which must contain apidoc json wrapped in "service", so like this:
{
    "service": {
        "apidoc": {
            "version": "0.9.6"
        },
        "name": "Checkout Api",
        "organization": {
            "key": "gilt"
        },
...
mchimirev commented 9 years ago

I updated api gateway to support this endpoint (POST) https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod/invocations/java_models_via_mobile_lambda

On Wed, Sep 16, 2015 at 9:06 AM, Sean Smith notifications@github.com wrote:

That setup sounds neat!

Curling the invocations endpoint ( https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/invocations/java_models_via_mobile_lambda), I get a "403 Forbidden" return code, and I was also able to make a local copy of apidoc spit out that error code. That makes me think that the generator is not actually receiving requests.

— Reply to this email directly or view it on GitHub https://github.com/mbryzek/apidoc/issues/368#issuecomment-140735829.

mbryzek commented 9 years ago

locally, i added the generator with this URL:

https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod

When invoking the code generator, I got back this error:

Generator failed with HTTP 200: Invalid json for class[com.bryzek.apidoc.generator.v0.models.Invocation]: (/files,List(ValidationError(List(error.path.missing),WrappedArray()))) (/source,List(ValidationError(List(error.path.missing),WrappedArray())))

We are expecting to get back an "Invocation":

http://www.apidoc.me/bryzek/apidoc-generator/0.9.30#model-invocation

containing two fields: files and source - and it looks like the document we got back did not have those keys.

Hope this helps! and I can't wait to see the output of the generator (esp mobile ones). and if still problematic - if you can, pls add me to your generator project and I can take a look.

When I made an attempt to add a generator I got a 500 Looking into this

my generator is seemingly available for every one yes - they are only global (awhile back we had finer grain controls on visibility, but it was confusing). Hopefully this is okay - but if not pls let me know and i'll reprioritize work to add permissions on generators.

generator "java_models_via_mobile_lambda" is stuck up there I can remove for you (and logged the need to make this available in UI @ https://github.com/mbryzek/apidoc/issues/370)

thanks!

On Wed, Sep 16, 2015 at 1:20 PM, mchimirev notifications@github.com wrote:

I updated api gateway to support this endpoint (POST)

https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod/invocations/java_models_via_mobile_lambda

On Wed, Sep 16, 2015 at 9:06 AM, Sean Smith notifications@github.com wrote:

That setup sounds neat!

Curling the invocations endpoint (

https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/invocations/java_models_via_mobile_lambda ), I get a "403 Forbidden" return code, and I was also able to make a local copy of apidoc spit out that error code. That makes me think that the generator is not actually receiving requests.

— Reply to this email directly or view it on GitHub https://github.com/mbryzek/apidoc/issues/368#issuecomment-140735829.

— Reply to this email directly or view it on GitHub https://github.com/mbryzek/apidoc/issues/368#issuecomment-140810570.

mchimirev commented 9 years ago

My assumption is that I should be serving java models from this URL:

POST https://o2v8ovbvyj.execute-api.us-east-1.amazonaws.com/prod/invocations/java_models_via_mobile_lambda

with Body looking like this:

{
    "service": {
        "apidoc": {
            "version": "0.9.6"
        },
        "name": "Checkout Api",
        "organization": {
            "key": "gilt"
        },
        "application": {
            "key": "checkout-api"
        },
        "namespace": "com.gilt.checkout.api.v0",
        "version": "0.1.50",
...

When I make that request (in POSTMAN), I do get back JSON containing source and files.

My guess is the endpoint where I'm serving generator from is not exactly the same as the one that apidoc is expecting.

mbryzek commented 8 years ago

Chatted w/ Mike - all seems fixed now