Skip to content

Commit

Permalink
Fixes the swagger API by copying it to a custom path
Browse files Browse the repository at this point in the history
This fixes the API by copying to a custom path in container while
building the image. Previously, the API used to stop working after
sometime or the file would be missing in container in some cases.
This could be one of the solution to fix it. but the main cause still
has to be fixed.

This will make the API not work locally as the file generated is in gen
and API server will look at the custom path we provided.

Signed-off-by: Shivam Mukhade <[email protected]>
  • Loading branch information
SM43 authored and tekton-robot committed Apr 27, 2021
1 parent 74739cc commit 613dc2c
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ WORKDIR /app
COPY --from=builder /go/src/github.com/tektoncd/hub/api/api-server /app/api-server

# For each new version, doc has to be copied
COPY gen/http/openapi3.yaml /app/gen/http/openapi3.yaml
COPY v1/gen/http/openapi3.yaml /app/v1/gen/http/openapi3.yaml
COPY gen/http/openapi3.json /app/docs/openapi3.json
COPY v1/gen/http/openapi3.json /app/docs/v1/openapi3.json

EXPOSE 8000

Expand Down
6 changes: 5 additions & 1 deletion api/design/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ var _ = Service("swagger", func() {
Path("/schema")
})

Files("/swagger.json", "gen/http/openapi3.yaml", func() {
// NOTE: The path is changed to docs/openapi3.json to make it work in container.
// Copying the gen as it is doesn't seems to work properly, so in dockerfile, swagger will
// file is copied to /docs. This will make the swagger api not work locally, as the file
// generated is in gen directory.
Files("/swagger.json", "docs/openapi3.json", func() {
Description("JSON document containing the API swagger definition")
})
})
2 changes: 1 addition & 1 deletion api/gen/http/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/gen/http/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ paths:
get:
tags:
- swagger
summary: Download gen/http/openapi3.yaml
summary: Download docs/openapi3.json
description: JSON document containing the API swagger definition
operationId: swagger#/schema/swagger.json
responses:
Expand Down
2 changes: 1 addition & 1 deletion api/gen/http/openapi3.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ paths:
get:
tags:
- swagger
summary: Download gen/http/openapi3.yaml
summary: Download docs/openapi3.json
description: JSON document containing the API swagger definition
operationId: swagger#/schema/swagger.json
responses:
Expand Down
10 changes: 5 additions & 5 deletions api/gen/http/swagger/server/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions api/v1/design/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ var _ = Service("swagger", func() {
HTTP(func() {
Path("/v1/schema")
})

Files("/swagger.json", "v1/gen/http/openapi3.yaml", func() {
// NOTE: The path is changed to docs/v1/openapi3.json to make it work in container.
// Copying the gen as it is doesn't seems to work properly, so in dockerfile, swagger will
// file is copied to /docs. This will make the swagger api not work locally, as the file
// generated is in gen directory.
Files("/swagger.json", "docs/v1/openapi3.json", func() {
Description("JSON document containing the API swagger definition")
})
})
2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ paths:
get:
tags:
- swagger
summary: Download v1/gen/http/openapi3.yaml
summary: Download docs/v1/openapi3.json
description: JSON document containing the API swagger definition
operationId: swagger#/v1/schema/swagger.json
responses:
Expand Down
2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi3.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ paths:
get:
tags:
- swagger
summary: Download v1/gen/http/openapi3.yaml
summary: Download docs/v1/openapi3.json
description: JSON document containing the API swagger definition
operationId: swagger#/v1/schema/swagger.json
responses:
Expand Down
10 changes: 5 additions & 5 deletions api/v1/gen/http/swagger/server/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 613dc2c

Please sign in to comment.