It does not work in Golang source code
ahmedxfn opened this issue · comments
Isn't this tool should work on any language (agnostic) ? when tried it on Golang, it returns nothing.
Example:
/*
* @api [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
* responses:
* 200:
* description: It works!
*/
func pet() {}
Hi there,
I think the syntax is a bit off, and this probably belongs under https://github.com/readmeio/swagger-inline/issues but I'll see if I can help.
- Comment should start with
@oas
:
/*
* @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
* responses:
* 200:
* description: It works!
*/
func pet() {}
How are you runnning the swagger-inline package? Should be similar to:
npx swagger-inline "./*.go" --base 'file.json' > api.json
Since oas
depends on swagger-inline
and the latter depends on comment-patterns
, It turns out the issue is in the comment-patterns
lib, it only reads the single line comment pattern in Golang as you can see here https://github.com/nknapp/comment-patterns/blob/master/languages/patterns/go.js.
Therefore there are two solutions either:
- Update
comment-patterns
to support muli-line comment pattern by addingmultiLineComment: require('./common/c-style.js').multiLine()
to/languages/patterns/go.js
file. - Switch to single line comment.
A new release is pushed to comment-patterns
, Go multi-line comment is now supported.