diff --git a/.gitignore b/.gitignore index 85e7c1d..07e6e47 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/.idea/ +/node_modules diff --git a/README.md b/README.md index d05cb8b..7bb81be 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,13 @@ Swagger (v2) and OpenAPI (v3) are specification for describing an API. Writing a You can import the yaml/json file in the [Swagger editor](http://editor.swagger.io/) and generate a client for any [supported languages](https://swagger.io/open-source-integrations/). +#Development +``` +docker-compose up -d --build +``` + +Connect to [http://localhost:8888]([http://localhost:8383]) + ## License IPFS OpenAPI is under the [MIT License](LICENSE.md). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d94c2d1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3.2' + +services: + ipfs: + image: jbenet/go-ipfs + volumes: + - ./docker/ipfs/start_ipfs.sh:/usr/local/bin/start_ipfs + - ./docker/ipfs/config_ipfs.sh:/usr/local/bin/config_ipfs + ports: + - 5001:5001 + - 4001:4001 + - 8080:8080 + expose: + - 5001 + - 4001 + - 8080 + + editor-synced: + image: lepetitbloc/swagger-editor:latest + ports: + - 8888:8080 + - 3000:3000 + - 3001:3001 + volumes: + - ./spec:/usr/share/nginx/html/data/ diff --git a/docker/ipfs/config_ipfs.sh b/docker/ipfs/config_ipfs.sh new file mode 100755 index 0000000..f3c1d7d --- /dev/null +++ b/docker/ipfs/config_ipfs.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 +ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET","POST","PUT"]' + diff --git a/docker/ipfs/start_ipfs.sh b/docker/ipfs/start_ipfs.sh new file mode 100755 index 0000000..c22073b --- /dev/null +++ b/docker/ipfs/start_ipfs.sh @@ -0,0 +1,42 @@ +#!/bin/sh +set -e +user=ipfs +repo="$IPFS_PATH" + +if [ `id -u` -eq 0 ]; then + echo "Changing user to $user" + # ensure folder is writable + su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo" + # restart script with new privileges + exec su-exec "$user" "$0" "$@" +fi + +# 2nd invocation with regular user +ipfs version + +if [ -e "$repo/config" ]; then + echo "Found IPFS fs-repo at $repo" +else + ipfs init +fi + +# if the first argument is daemon +if [ "$1" = "daemon" ]; then + # filter the first argument until + # https://github.com/ipfs/go-ipfs/pull/3573 + # has been resolved + shift +else + # print deprecation warning + # go-ipfs used to hardcode "ipfs daemon" in it's entrypoint + # this workaround supports the new syntax so people start setting daemon explicitly + # when overwriting CMD + echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2 + echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2 + echo "DEPRECATED: see the following PRs for more information:" >&2 + echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3573" >&2 + echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3685" >&2 +fi + +config_ipfs +exec ipfs daemon "$@" \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..cf6067c --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "ipfs-swagger", + "version": "1.0.0", + "description": "**IPFS** Rest API swagger specification document in Yml and Json (OpenAPI).", + "main": "index.js", + "directories": { + "doc": "docs" + }, + "scripts": { + "start": "browser-sync start --config bs-config.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/LePetitBloc/ipfs-swagger.git" + }, + "keywords": [ + "ipfs", + "swagger", + "swagger-editor", + "docker" + ], + "author": "JulesAaelio", + "license": "ISC", + "bugs": { + "url": "https://github.com/LePetitBloc/ipfs-swagger/issues" + }, + "homepage": "https://github.com/LePetitBloc/ipfs-swagger#readme", + "devDependencies": { + "browser-sync": "^2.24.5" + } +} diff --git a/spec/swagger.yml b/spec/swagger.yml new file mode 100644 index 0000000..e69de29