Error: No comment-part had a match. This should not happen
macasas opened this issue · comments
Same Error previously raised here. 361
Same steps to recreate.
Running on OSX 10.12.6
My base specification is 3.0.3, so not sure how this can be solved in v12 as described in linked issue? Perhaps v1.2?
This happens with both json and yml for me, when running oas validate
and oas generate
I'm unable to replicate this with the latest version of the library (17.4.3):
$ cat index.js
/* @oas [post] /pets/{category}
* description: "List all pets in a category"
* parameters:
* - (path) category=all* {String} Pet category
* - (query) limit {Integer:int32} Amt returned
* - (body) search {String} Search pet details
* - (body) strict {Boolean} Exact matches?
*/
routes.get('/pets/:category', getPets);
$ npx oas init
This will help you set up an OpenAPI 3.0 Definition in your codebase, so
you can start documenting your API!
? Name of the API debug-578
? Version number 1.0.0
? License
? Full Base URL https://api.example.com
? Output JSON or YAML file 1.0.0.json
======================
SUCCESS!
We've created your new OpenAPI file at 1.0.0.json.
You can document each endpoint right above the code. Just use the
following syntax in a comment above the code:
/*
* @oas [get] /pet/{petId}
* description: Returns all pets from the system that the user has access to
* parameters:
* - (path) petId=2* {Integer} The pet ID
* - (query) limit {Integer:int32} The number of resources to return
*/
route.get("/pet/:petId", pet.show);
For more information on this syntax, see https://github.com/readmeio/swagger-inline
To see what you can do with your API, type oas help.
To generate an OAS file, type oas generate. To publish it, type oas host!
$ npx oas generate 1.0.0.json
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "debug-578"
},
"servers": [
{
"url": "https://api.example.com"
}
],
"paths": {
"/pets/{category}": {
"post": {
"description": "List all pets in a category",
"parameters": [
{
"in": "path",
"name": "category",
"required": true,
"description": "Pet category",
"schema": {
"type": "string",
"default": "all"
}
},
{
"in": "query",
"name": "limit",
"description": "Amt returned",
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Successful response"
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"search": {
"type": "string",
"description": "Search pet details"
},
"strict": {
"type": "boolean",
"description": "Exact matches?"
}
}
}
}
}
}
}
}
}
}
Can you supply the error trace you're seeing?
Since oas
doesn't ship with a --version
command I'm not sure of any way with npx
to tell you what version's being loaded but this bug was resolved in the swagger-inline
page that oas
uses in readmeio/swagger-inline#196, so all the latest versions of oas
and swagger-inline
should not be experiencing it.
As for the no content in the JSON file I'm not sure what's up there, I need more data from how you're using it and where and how your files are set up, to debug. If you're able to fully replicate it on a codebase you can share with us that'd be immensely helpful.