oas
oas copied to clipboard
Error: No comment-part had a match. This should not happen
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?
Hi Jon
Thanks for response. I do not really understand what’s going on with this. I am reading how to use it on https://openap.is/ I npm install -g oas on Friday, so assume the latest version, and get the no comment-part error Since my post I have un-installed, reinstalled, rebooted a few times etc.. trying to get this working. Then I try your example and it works. (Perhaps something was updated between Friday and Saturday?) I go back to my project and it works, sort of. No more error, but no content in the json file either. Perhaps this is normal behaviour and I need to copy/paste from the terminal window each time?
I cannot work out how to check the library version i.e. 17.4.3 All typical formats —version, —version, -V etc.. do not return anything Oas help does not display anything. The only version is in the base file, 3.0.3
Thanks for your help. Dave
On 7 Jan 2022, at 17:30, Jon Ursenbach @.***> wrote:
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?
— Reply to this email directly, view it on GitHub https://github.com/readmeio/oas/issues/578#issuecomment-1007593668, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG6GATPZIAGN44Y7RTLEZ3UU4PKHANCNFSM5LO2WVTA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.
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 https://github.com/readmeio/swagger-inline/pull/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.