Hello guys, how can i load in docker under swagger...
# docker
m
Hello guys, how can i load in docker under swagger <domain> in docker the glue documentation generated from this command
docker/sdk console rest-api:generate:documentation
? I've seen that this command generate the
spryker_rest_api.schema.yml
file under
src/Generated/Glue/Specification
but me is not clear how to load this definition into swagger... which is the public url, if exists one? thanks!
f
You can paste it i.e. http://editor.swagger.io/
h
Hi Giovanni, Do you use the feature in docker SDK https://documentation.spryker.com/docs/spryker-in-docker-services#swagger-ui ?
m
@high-pencil-62400 yes.. i can see the swagger app with my url.. but the problem is that i don't understand how to load the spryker generated documentation into swagger application web..
Copy code
swagger:
    engine: swagger-ui
    endpoints:
        swagger.<our domain>.com:
h
It should be automatically done. https://github.com/spryker/docker-sdk/blob/master/images/swagger/Dockerfile Try
docker/sdk up
after generating spec. It should build swagger image again and catch generated yml,
m
unfortunately it s not happend.... i miss something? i just update docker sdk project and then bootstrap deploy.dev.yml and up
h
When have you generated spryker_rest_api.schema.yml? Before up or after?
m
ah maybe after... ok.. i can try to re-up docker.. i need only up or maybe before also bootstrap and then up?
h
just up. Bootstrap is only needed when SDK updated or deploy yml changed.
m
ok. i tried to up again docker (with rest api documentation already generated) but under swagger app there is always the default url about petstore and not the spryker yml... maybe i do something wrong??!
h
It should be OOTB. Would you be so kind to run the following:
Copy code
docker exec spryker_dev_swagger_1 ls -al /var/specs/
m
Copy code
docker exec spryker_b2b_dev_swagger_1 ls -la /var/specs/

total 228
drwxr-xr-x    2 root     root           102 Jan 29 10:16 .
drwxrwxrwx    1 root     root          4096 Jan 28 10:12 ..
-rw-r--r--    1 root     root        227756 Jan 29 10:15 spryker_rest_api.schema.yml
is there!
h
Copy code
docker exec spryker_b2b_dev_swagger_1 'echo $SWAGGER_JSON'
m
with your command i get
Copy code
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"echo $SWAGGER_JSON\": executable file not found in $PATH": unknown
withou single quote, just echo $SWAGGER_JSON then i get empty response from container
h
ok.
docker exec -it spryker_b2b_dev_swagger_1 bash
and inside
echo $SWAGGER_JSON
m
ok. i wanted just this try.. 1 min
h
P.S. And in dev mode you do not need to rebuild swagger image as it just mounts the folder.
m
SWAGGER_JSON path variable is also right:
/var/specs/spryker_rest_api.schema.yml
yes.. understand..
i checked later..
h
So everything is set ok. I wonder if Swagger has cached in browser. Would you able to open it in Private mode?
m
ok, i try..
no.. always the same
h
May be permission issue.
m
how can we check if a permission issue?
h
docker logs spryker_b2b_dev_swagger_1
m
no errors in log... only the access log infos
h
Are you on linux?
m
no, macos
h
It seems we are giving everything for swagger UI. Let’s try the following:
Copy code
docker run -p 8080:8080 -e BASE_URL=/swagger -e SWAGGER_JSON=/var/specs/swagger.yml -v $(pwd)/src/Generated/Glue/Specification/spryker_rest_api.schema.yml:/var/specs/swagger.yml swaggerapi/swagger-ui
And open localhost:8080/swagger
I see this
m
it works!
h
And the question. Why it does not work for swagger in docker setup as it is the same?
docker inspect spryker_b2b_dev_swagger_1
m
i don't know.. maybe swagger is expecting swagger.yml file and not spryker_rest_api..... filename... because the mount works in docker setup
question: it does work on your b2b local docker?
h
It does not matter you can change swagger.yml with any other name in the command I gave.
m
ok..
strange.. i can debug in deep maybe later or tomorrow and i can ping u if i find smth...
h
This swagger stuff is so isolated - it does not care on the project. As only mount and env var is set.
m
yes i see
h
docker inspect spryker_b2b_dev_swagger_1 | grep spryker_rest_api
Copy code
docker inspect spryker_b2b_dev_swagger_1 | grep SWAGGER_JSON
List the output here please. Thanks
m
first command:
Copy code
"SWAGGER_JSON=/var/specs/spryker_rest_api.schema.yml",
second command:
Copy code
"SWAGGER_JSON=/var/specs/spryker_rest_api.schema.yml",
h
docker inspect -f '{{ .Mounts }}' spryker_b2b_dev_swagger_1
But as I remember file was there.
m
[{bind /Volumes/Loeffelhardt-Projekte/el-online.loeffelhardt.local/project/src/Generated/Glue/Specification /var/specs rw true rprivate}]
it seem good... i will try today by my collegue docker instance... in the case there works then it is only smth strange on my system...
h
Strange - it must work. Ok. Let’s do the reset. docker/sdk down docker rm spryker_b2b_dev_swagger_1 docker/sdk run
m
ok.. i will try and give u feedback in 1 hour...
it works now!!
thank u!
h
Hmm. It seems swagger just keeps some state internally.
m
probably yes...
h
We are willing to change the behavior completely by introducing Glue endpoint for specification. At that point it won’t go via file but URL.
Thank you for using our docker SDK and feedbacks!
m
yes... your docker SDK is very good!! thank u!
😎 1