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

カテゴリの中にカテゴリがネストしてるとコケる #20

Closed
tenmihi opened this issue Aug 22, 2019 · 0 comments · Fixed by #21
Closed

カテゴリの中にカテゴリがネストしてるとコケる #20

tenmihi opened this issue Aug 22, 2019 · 0 comments · Fixed by #21

Comments

@tenmihi
Copy link
Collaborator

tenmihi commented Aug 22, 2019

再現環境

  • hariko v1.2.0
  • node v8.15.0

現象

v1.2.0でgruntを通して走らせたところコケてしまいます

Running "hariko:apiblueprint" (hariko) task
[16:31:27:945][INFO] Run a resource in the output mode.
[16:31:27:946][INFO]   destination:  mock/hariko
Warning: Cannot read property 'href' of undefined Use --force to continue.

Aborted due to warnings.

Grunttaskは以下のとおりです

apiblueprint:
  hariko:
    options:
      file: 'docs/api/**/*.{md,apib}'
      port: 3000
      host: '0.0.0.0'
      watch: true
      time: true
      cors: true
      exclude: [
      ]
      proxy: 'http://0.0.0.0:3001'
      output: 'mock/hariko'

用意したapiドキュメント

# Group HOGE

# HOGEAPI [GET /api/hoge/{key}]

+ Relation: self

+ Parameters

    + key (string, required) ... キー

+ Response 200 (application/json; charset=utf8)
    + Attributes

    + Headers

    + Body

            {
              error: {},
              contents: [
                {
                  name: 'HOGE',
                },
                {
                  name: 'FUGA',
                }
              ]
            }

parseされた内容

const annotations = AnnotationsStructure.create()
data.content[0].content.forEach((content) => {

index.ts L12にconsole.log(data)を挿入して得られたjsonになります

{
  "element": "parseResult",
  "content": [
    {
      "element": "category",
      "meta": {
        "classes": {
          "element": "array",
          "content": [
            {
              "element": "string",
              "content": "api"
            }
          ]
        },
        "title": {
          "element": "string",
          "content": ""
        }
      },
      "content": [
        {
          "element": "category",
          "meta": {
            "classes": {
              "element": "array",
              "content": [
                {
                  "element": "string",
                  "content": "resourceGroup"
                }
              ]
            },
            "title": {
              "element": "string",
              "content": "HOGE"
            }
          },
          "content": [
            {
              "element": "resource",
              "meta": {
                "title": {
                  "element": "string",
                  "content": "HOGEAPI"
                }
              },
              "attributes": {
                "href": {
                  "element": "string",
                  "content": "/api/hoge/{key}"
                }
              },
              "content": [
                {
                  "element": "transition",
                  "meta": {
                    "title": {
                      "element": "string",
                      "content": "HOGEAPI"
                    }
                  },
                  "attributes": {
                    "relation": {
                      "element": "string",
                      "content": "self"
                    },
                    "href": {
                      "element": "string",
                      "content": "/api/hoge/{key}"
                    },
                    "hrefVariables": {
                      "element": "hrefVariables",
                      "content": [
                        {
                          "element": "member",
                          "meta": {
                            "description": {
                              "element": "string",
                              "content": "キー"
                            },
                            "title": {
                              "element": "string",
                              "content": "string"
                            }
                          },
                          "attributes": {
                            "typeAttributes": {
                              "element": "array",
                              "content": [
                                {
                                  "element": "string",
                                  "content": "required"
                                }
                              ]
                            }
                          },
                          "content": {
                            "key": {
                              "element": "string",
                              "content": "key"
                            },
                            "value": {
                              "element": "string"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "content": [
                    {
                      "element": "httpTransaction",
                      "content": [
                        {
                          "element": "httpRequest",
                          "attributes": {
                            "method": {
                              "element": "string",
                              "content": "GET"
                            }
                          },
                          "content": []
                        },
                        {
                          "element": "httpResponse",
                          "attributes": {
                            "statusCode": {
                              "element": "string",
                              "content": "200"
                            },
                            "headers": {
                              "element": "httpHeaders",
                              "content": [
                                {
                                  "element": "member",
                                  "content": {
                                    "key": {
                                      "element": "string",
                                      "content": "Content-Type"
                                    },
                                    "value": {
                                      "element": "string",
                                      "content": "application/json; charset=utf8"
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          "content": [
                            {
                              "element": "asset",
                              "meta": {
                                "classes": {
                                  "element": "array",
                                  "content": [
                                    {
                                      "element": "string",
                                      "content": "messageBody"
                                    }
                                  ]
                                }
                              },
                              "attributes": {
                                "contentType": {
                                  "element": "string",
                                  "content": "application/json; charset=utf8"
                                }
                              },
                              "content": "{\n  error: {},\n  contents: [\n    {\n      name: 'HOGE',\n    },\n    {\n      name: 'FUGA',\n   }\n  ]\n}\n"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
@rymizuki rymizuki pinned this issue Aug 23, 2019
rymizuki added a commit that referenced this issue Aug 31, 2019
rymizuki added a commit that referenced this issue Aug 31, 2019
rymizuki added a commit that referenced this issue Sep 9, 2019
#20 カテゴリがネストしたときに再帰的にresourceを探索してパースする
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant