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

Can't generate index.md when "paramaters" field exists #8

Open
magdiel01 opened this issue Sep 17, 2016 · 5 comments
Open

Can't generate index.md when "paramaters" field exists #8

magdiel01 opened this issue Sep 17, 2016 · 5 comments

Comments

@magdiel01
Copy link

magdiel01 commented Sep 17, 2016

"swagger2slate.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 927"

nix-swagger2slate-docs_ -bash _88x76
{
"swagger": "2.0",
"info": {
"title": "My First API",
"version": "0.1"
},
"paths": {
"/api/resource.json": {
"get": {
"parameters": [
{
"name": "body",
"description": "Measure value object that needs to be added.",
"required": true,
"type": "array",
"items": {},
"paramType": "body"
}
],
"responses": {
"200": {
"description": "An example resource"
}
}
}
}
},
"definitions": {}
}

@saikrishnaradarapu
Copy link

Hi,
How are using this project??
Can you elaborate me, because I am new to php.

@saikrishnaradarapu
Copy link

saikrishnaradarapu commented Oct 7, 2016

$ ./swagger2slate.phar convert ../swagger.json -o source/index.md

giving me the following

PHP Warning: file_get_contents(../swagger.json): failed to open stream: No such file or directory in phar:///home/Desktop/swagger2slate.phar/index.php on line 15
swagger version must be 2.0

@MikeRalphson
Copy link

@magdiel01 your Swagger definition fails validation, maybe that's it? Try

{
"swagger": "2.0",
"info": {
"title": "My First API",
"version": "0.1"
},
"paths": {
"/api/resource.json": {
"get": {
"parameters": [
{
"name": "body",
"description": "Measure value object that needs to be added.",
"required": true,
"schema": {
  "type": "array",
  "items": {}
},
"in": "body"
}
],
"responses": {
"200": {
"description": "An example resource"
}
}
}
}
},
"definitions": {}
}

Another (maintained) solution for converting Swagger (OpenAPI) to Slate is https://github.com/mermade/widdershins

@magdiel01
Copy link
Author

@MikeRalphson It fails because when I pasted the text into this thread it loses the indentation,
thanks for the recommended solution.

@MikeRalphson
Copy link

@magdiel01 no problem. It isn't just the indentation though (that's optional for JSON / Swagger) - I've changed

"name": "body",
"description": "Measure value object that needs to be added.",
"required": true,
"type": "array",
"items": {},
"paramType": "body"

to

"name": "body",
"description": "Measure value object that needs to be added.",
"required": true,
"schema": {
  "type": "array",
  "items": {}
},
"in": "body"

You can check a Swagger definition is a valid at http://bigstickcarpet.com/swagger-parser/www/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants