znai: include-open-api plugin doesn't understand `basePath`.

When path includes basePath(“path”:“/rest/api/whoami”) in the plugin, --preview throws the below exception. If I don’t include basePath(“path”:“/api/whoami”) in the plugin, --preview doesn’t throw an exception. Here are a stack trace, swagger.json and index.md.

Exception in thread "main" java.lang.RuntimeException: 
markup parsing error:
    TOC item: /index
    full path: /home/hwansoo/workspace/test/znai/index.md

java.lang.RuntimeException: cannot find operation: get /rest/api/whoami

	at org.testingisdocumenting.znai.website.WebSite.throwParsingErrorMessage(WebSite.java:555)
	at org.testingisdocumenting.znai.website.WebSite.parseMarkupAndUpdateTocItemAndSearch(WebSite.java:547)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
	at org.testingisdocumenting.znai.website.WebSite.parseMarkups(WebSite.java:489)
	at org.testingisdocumenting.znai.website.WebSite.parse(WebSite.java:188)
	at org.testingisdocumenting.znai.website.WebSite.parseAndDeploy(WebSite.java:175)
	at org.testingisdocumenting.znai.website.WebSite$Configuration.deployTo(WebSite.java:1023)
	at org.testingisdocumenting.znai.cli.ZnaiCliApp.generateDocs(ZnaiCliApp.java:193)
	at org.testingisdocumenting.znai.cli.ZnaiCliApp.start(ZnaiCliApp.java:96)
	at org.testingisdocumenting.znai.cli.ZnaiCliApp.start(ZnaiCliApp.java:67)
	at com.twosigma.testing.documenting.TsDocumentationCliApp.main(TsDocumentationCliApp.java:69)
Caused by: java.lang.RuntimeException: error handling include plugin <open-api>
  free param: swagger.json
  opts: {"method":"get","path":"/rest/api/whoami","autoSection":true}

cannot find operation: get /rest/api/whoami

swagger.json

{
  "consumes": [
    "application/json"
  ],
  "definitions": {
    "Error": {
      "properties": {
        "errors": {
          "type": "object"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "message"
      ],
      "title": "Error",
      "type": "object"
    },
    "User": {
      "description": "A User model.",
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "User",
      "type": "object"
    }
  },
  "host": "localhost",
  "info": {
    "description": "HelloApp API description goes here.",
    "title": "HelloApp API",
    "version": "1.0.0"
  },
  "paths": {
    "/api/whoami": {
      "get": {
        "description": "Return the user the request was authenticated as (HTTP REMOTE_USER).",
        "operationId": "whoami",
        "responses": {
          "200": {
            "description": "A User model.",
            "schema": {
              "$ref": "#/definitions/User"
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "whoami"
        ]
      }
    }
  },
  "produces": [
    "application/json"
  ],
  "schemes": [],
  "basePath": "/rest",
  "securityDefinitions": {},
  "swagger": "2.0"
}

index.md

# Your product

:include-open-api: swagger.json {method: "get", path: "/rest/api/whoami", autoSection: true}

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

Yes agree. Next PR should address it. In addition to removing autoSection you can make generator of swagger to generate summary field to fix NPE