Code Monkey home page Code Monkey logo

Comments (17)

zdne avatar zdne commented on July 28, 2024

@korpa

Can you provide an example of the blueprint in question? Seems to work well on my side.

For example try following snippet in http://apiblueprint.org/#you_name_it


# Group My Group

# Message [/messages/{id}]

## Retrieve Message [GET]
+ Response 200 (text/plain)

        Hello World!

## Delete Message [DELETE]
+ Response 204

from protagonist.

korpa avatar korpa commented on July 28, 2024

Hi zdne,

I have a more complex blueprint.

I use _resource groups_ described in
https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md#ResourceGroups
combined with _resource model sections_
https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md#ResourceModelSection

Please find a blueprint file and the outputs of 0.5.3 and 0.5.4 below:

HOST: http://xxx.xxx

# yyy API v1 for zzz
A simple [yyy](http://yyy.yyy) API.

# Group Authentication
This API uses "basic authentication". Add token to loginname and leave password empty.
If using cURL, the command would look like: <code>curl -u token: https://xxx.xxx</code> Please note the colon after the token.

# Group Transactions

# Message [/v1/xxx/yyy]


## Foo [GET]
Foo bar bla 
**Example:** <pre class="prettyprint">curl -u token: "https://xxx.xxx/v1/xxx/yyy?startDate=2013-10-01 \
   &endDate=2013-10-31"</pre>
+ Parameters
    + startDate (required, date, `2013-10-01`) ... start date
    + endDate (required, date, `2013-10-31`) ... end date

+ Response 201 (application/json; charset=utf-8)
    {
        "transactions" : [
            {
                "id": 116664,
                ...
            },
            {
                "id": 116665,
                ...
            }
        ],
        "meta": {
            "paging": {
                "page": 1,
                "pageSize": 2,
                "pageCount": 3,
                "total": 5
            }
        }
    }

What you see below is the output of console.log(result.ast.resourceGroups);

$ npm install [email protected]
$ node app.js 
[ { name: 'Authentication',
    description: 'This API uses "basic authentication". Add token to loginname and leave password empty.\nIf using cURL, the command would look like: <code>curl -u token: https://xxx.xxx</code> Please note the colon after the token.\n\n',
    resources: [] },
  { name: 'Transactions',
    description: '',
    resources: [ [Object] ] } ]

Then I update from 0.5.3 to 0.5.4

$ npm install [email protected]
$ node app.js 
[ { name: '',
    description: '# Group Authentication\nThis API uses "basic authentication". Add token to loginname and leave password empty.\nIf using cURL, the command would look like: <code>curl -u token: https://xxx.xxx</code> Please note the colon after the token.\n\n',
    resources: [] },
  { name: '',
    description: '# Group Transactions\n\n',
    resources: [ [Object] ] } ]

You see, that after updating from 0.5.3 to 0.5.4, the resource groups are broken.
Hope this helps.

from protagonist.

korpa avatar korpa commented on July 28, 2024

Strange thing. I tried the example you asked me for:

# Group Messages

# Message [/messages/{id}]

## Retrieve Message [GET]
+ Response 200 (text/plain)

        Hello World!

## Delete Message [DELETE]
+ Response 204

With 0.5.3 everything works fine:

$ npm install [email protected]
$ node app.js 
[ { name: 'Messages', description: '', resources: [ [Object] ] } ]

But as soon as I update to 0.5.4, I get following error:

$ npm install [email protected]
$ node app.js 
{ code: 1,
  message: 'parser exception: \'basic_string::substr\'',
  location: [] }

from protagonist.

kuba-kubula avatar kuba-kubula commented on July 28, 2024

@korpa Would you please provide info about your OS, npm -ls and node -v with npm -v, please?
Thank you.

Because everything works for me with Mac OSX 10.9 + node 0.8.26 + npm 1.2.30...

from protagonist.

korpa avatar korpa commented on July 28, 2024

Here you go:
Ubuntu 13.10
node 0.10.11
npm 1.3.7

from protagonist.

zdne avatar zdne commented on July 28, 2024

@korpa

I have added a simple CLI parser (protagonist.js) and a sample blueprint file to the test directory. Repackaged as v0.5.5 and published the npm.

Ran following:

$ npm install [email protected]
$ cd node_modules/protagonist/test/
$ node protagonist.js sample.md

I can see the group name as expected. Therefore I am unable to reproduce this issue.

Tested on OS X 10.9 both with Node.jd v0.8.25 and v0.10.22 as well as on Ubuntu 12.04.1 LTS with v0.8.23.

Can you please try to run the command above and see whether you can reproduce the issue?

from protagonist.

korpa avatar korpa commented on July 28, 2024

Thank you very much.

Did what you asked me for:

$ node protagonist.js sample.md
{                                                                                          
  "code": 1,                                                                                    
  "message": "parser exception: 'basic_string::substr'",                                             
  "location": []                                                                                             
}

Then double checked how your test behaves with 0.5.3. Therefore copied the test folder to the root directory of my project, downgraded to 0.5.3 and copied the test files to the modules test directory. Run your test script and - voila - it worked.

$ cp -r node_modules/protagonist/test/ .
$ npm install [email protected]
$ cp test/* node_modules/protagonist/test
$ cd node_modules/protagonist/test
$ node protagonist.js sample.md
{
  "ast": {
    "_version": "1.0",
    "metadata": {},
    "name": "",
    "description": "",
    "resourceGroups": [
      {
        "name": "Messages",
        "description": "",
        "resources": [
          {
            "name": "Message",
            "description": "",
            "uriTemplate": "/messages/{id}",
            "model": {},
            "parameters": {},
            "headers": {},
            "actions": [
              {
                "name": "Retrieve Message",
                "description": "",
                "method": "GET",
                "parameters": {},
                "headers": {},
                "examples": [
                  {
                    "name": "",
                    "description": "",
                    "requests": [],
                    "responses": [
                      {
                        "name": "200",
                        "description": "",
                        "headers": {
                          "Content-Type": {
                            "value": "text/plain"
                          }
                        },
                        "body": "Hello World!\n",
                        "schema": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "Delete Message",
                "description": "",
                "method": "DELETE",
                "parameters": {},
                "headers": {},
                "examples": [
                  {
                    "name": "",
                    "description": "",
                    "requests": [],
                    "responses": [
                      {
                        "name": "204",
                        "description": "",
                        "headers": {},
                        "body": "",
                        "schema": ""
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "warnings": []
}

from protagonist.

korpa avatar korpa commented on July 28, 2024

I did some more tests now. Therefore downloaded the latest version of node.

  • Running your test against 0.5.3 works
  • Running your test against 0.5.5 failed as with the standard Ubuntu node package (v0.10.11):
/opt/node-v0.10.22-linux-x64/bin/node protagonist.js sample.md
{
  "code": 1,
  "message": "parser exception: 'basic_string::substr'",
  "location": []
}

By the way. The Ubuntu you used for your tests, is it a 32bit or 64bit system?

from protagonist.

korpa avatar korpa commented on July 28, 2024

I quickly set up a virtual machine with Debian 7.2 (64bit)

$ lsb_release -d
Description:    Debian GNU/Linux 7.2 (wheezy)
$ npm -v
1.3.14
$ node -v
v0.10.22

When I run the test script multiple times, I sometimes get a "seg fault" and sometimes a "parser exception":

root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
Segmentation fault
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
Segmentation fault
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
{
  "code": 1,
  "message": "parser exception: 'basic_string::substr'",
  "location": []
}
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
Segmentation fault
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
Segmentation fault
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
{
  "code": 1,
  "message": "parser exception: 'basic_string::substr'",
  "location": []
}
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
{
  "code": 1,
  "message": "parser exception: 'basic_string::substr'",
  "location": []
}
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 
Segmentation fault
root@test:/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md 

Again 0.5.3 works fine:

/opt/protagonist/node_modules/protagonist/test# node protagonist.js sample.md
{
  "ast": {
    "_version": "1.0",
    "metadata": {},
    "name": "",
    "description": "",
    "resourceGroups": [
      {
        "name": "Messages",
        "description": "",
        "resources": [
          {
            "name": "Message",
            "description": "",
            "uriTemplate": "/messages/{id}",
            "model": {},
            "parameters": {},
            "headers": {},
            "actions": [
              {
                "name": "Retrieve Message",
                "description": "",
                "method": "GET",
                "parameters": {},
                "headers": {},
                "examples": [
                  {
                    "name": "",
                    "description": "",
                    "requests": [],
                    "responses": [
                      {
                        "name": "200",
                        "description": "",
                        "headers": {
                          "Content-Type": {
                            "value": "text/plain"
                          }
                        },
                        "body": "Hello World!\n",
                        "schema": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "Delete Message",
                "description": "",
                "method": "DELETE",
                "parameters": {},
                "headers": {},
                "examples": [
                  {
                    "name": "",
                    "description": "",
                    "requests": [],
                    "responses": [
                      {
                        "name": "204",
                        "description": "",
                        "headers": {},
                        "body": "",
                        "schema": ""
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "warnings": []
}

If it helps I can give you access to this virtual machine.

from protagonist.

zdne avatar zdne commented on July 28, 2024

@korpa

that seems really fishy. Can you move one layer bellow and try to build & test Snow Crash?

from protagonist.

korpa avatar korpa commented on July 28, 2024

Seems to work (commit apiaryio/snowcrash@607adbc)

$ make test
[snip]
All tests passed (1796 assertions in 178 test cases)
$ make snowcrash
make -C ./build V=1 snowcrash
make[1]: Entering directory `/opt/snowcrash/build'
  g++  -I../src -I../src/snowcrash -I../cmdline  -pthread -fPIC -Wall -Wextra -Wno-unused-parameter -m64  -MMD -MF out/Release/.deps/out/Release/obj.target/snowcrash/src/snowcrash/snowcrash.o.d.raw  -c -o out/Release/obj.target/snowcrash/src/snowcrash/snowcrash.o ../src/snowcrash/snowcrash.cc
  flock out/Release/linker.lock g++ -pthread -rdynamic -m64  -o out/Release/snowcrash -Wl,--start-group out/Release/obj.target/snowcrash/src/snowcrash/snowcrash.o out/Release/obj.target/libsnowcrash.a out/Release/obj.target/libsundown.a -Wl,--end-group 
  LINK(target) out/Release/snowcrash: Finished
make[1]: Leaving directory `/opt/snowcrash/build'
mkdir -p ./bin
cp -f ./build/out/Release/snowcrash ./bin/snowcrash

$ cat sample.md | ./bin/snowcrash -f json
{
  "_version": "1.0",
  "metadata": {},
  "name": "",
  "description": "",
  "resourceGroups": [
    {
      "name": "Messages",
      "description": "",
      "resources": [
[snip]
      ]
    }
  ]
}

OK.

from protagonist.

zdne avatar zdne commented on July 28, 2024

@korpa

I am looking into possibly related #5 - can you please confirm your compiler version (gcc -v)? Thanks.

from protagonist.

korpa avatar korpa commented on July 28, 2024

Here you go:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) 

from protagonist.

zdne avatar zdne commented on July 28, 2024

@korpa

Thanks! I believe I have found the lead. Will keep you posted.

from protagonist.

korpa avatar korpa commented on July 28, 2024

Cool. Many thanks for your effort.

from protagonist.

korpa avatar korpa commented on July 28, 2024

Perfect. Will test next week, when return to work on my API project.

from protagonist.

zdne avatar zdne commented on July 28, 2024

@korpa

Remember the Aglio first needs to bump Protagonist dependency to v0.6.1.

from protagonist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.