Skip to content

Commit

Permalink
feat: generate go server and ts client
Browse files Browse the repository at this point in the history
use openapi generator to start building the api
  • Loading branch information
Jesse0Michael committed May 18, 2020
1 parent c8c9ff5 commit dc38093
Show file tree
Hide file tree
Showing 42 changed files with 2,401 additions and 297 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build
on:
push:

jobs:
test:
name: test
runs-on: ubuntu-latest
container: golang:1.14-alpine
env:
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Test
run: |
go mod download
mkdir coverage
go test -v ./internal/... -cover -coverprofile=coverage/info.cov
- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: .coverage/info.cov
5 changes: 5 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OpenAPI Generator Ignore

main.go

Dockerfile
1 change: 1 addition & 0 deletions .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.0.0-SNAPSHOT
5 changes: 5 additions & 0 deletions .openapi-generator/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sourceFolder": "internal",
"packageName": "opendam",
"featureCORS": true
}
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
.PHONY: build test

gen:
docker run -v ${PWD}:/open-dam openapitools/openapi-generator-cli generate -i /open-dam/api/openapi.yaml -g go-server -o /open-dam -c /open-dam/config.json --git-user-id open-dam --git-repo-id open-dam-api --enable-post-process-file -t /open-dam/.openapi-generator/templates/go-server
# GO_POST_PROCESS_FILE="gofmt -w"
docker run -v ${PWD}:/open-dam openapitools/openapi-generator-cli generate -i /open-dam/api/openapi.yaml -g go-server -o /open-dam -c /open-dam/.openapi-generator/config.json --git-user-id open-dam --git-repo-id open-dam-api
# -e GO_POST_PROCESS_FILE="gofmt -w"
# -t /open-dam/.openapi-generator/templates/go-server


docker run -v ${PWD}:/open-dam openapitools/openapi-generator-cli generate -i /open-dam/api/openapi.yaml -g typescript-node -o /open-dam/client/ts/ --git-user-id open-dam --git-repo-id open-dam-api --additional-properties=npmName=@open-dam/open-dam-api,npmVersion=1.0.0

gen-docs:
# Requrires [Redoc](https://github.com/Redocly/redoc)
# `npm install redoc-cli -g --save`
redoc-cli bundle api/spec.yaml -o docs/index.html --options.disableSearch --options.hideDownloadButton
redoc-cli bundle api/openapi.yaml -o docs/index.html --options.disableSearch --options.hideDownloadButton

build:
go build -o bin/open-dam-api
go build -o ./bin/open-dam-api ./cmd/open-dam-api/

build-docker:
docker build -t open-dam-api .
docker build -t open-dam-api -f build/Dockerfile .

test:
go test -v ./internal/...

test-coverage:
if [ ! -d coverage ]; then mkdir coverage; fi
go test -coverpkg ./internal/... -coverprofile coverage/coverage.out ./... && go tool cover -html=coverage/coverage.out

run:
docker run -p 8080:8080 open-dam-api
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# Open DAM API
The API for an pen source digital asset manager called Open DAM. Built to help teams and individuals manage, search, and retrieve digital assets.
# Go API Server for opendam

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview
This server was generated by the [openapi-generator]
(https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
-

To see how to make this your own, look here:

[README](https://openapi-generator.tech)

- API version: 0.0.0
- Build date: 2020-05-18T05:57:30.028Z[GMT]


### Running the server
To run the server, follow these simple steps:

```
go run main.go
```

To run the server in a docker container
```
docker build --network=host -t opendam .
```

Once image is built use
```
docker run --rm -it opendam
```


Loading

0 comments on commit dc38093

Please sign in to comment.