Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/samples-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
- 'samples/server/petstore/go-echo-server/**'
- 'samples/server/petstore/go-api-server/**'
- 'samples/server/petstore/go-chi-server/**'
- 'samples/server/others/go-server/no-body-path-params/**'
- 'samples/server/others/go-server/**'
pull_request:
paths:
- 'samples/server/petstore/go-echo-server/**'
- 'samples/server/petstore/go-api-server/**'
- 'samples/server/petstore/go-chi-server/**'
- 'samples/server/others/go-server/no-body-path-params/**'
- 'samples/server/others/go-server/**'

jobs:
build:
Expand All @@ -26,6 +26,7 @@ jobs:
- samples/server/petstore/go-api-server/
- samples/server/petstore/go-chi-server/
- samples/server/others/go-server/no-body-path-params/
- samples/server/others/go-server/optional-body/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
Expand Down Expand Up @@ -58,4 +59,4 @@ jobs:
go mod tidy
- name: Run tests
working-directory: ${{ matrix.sample }}
run: go test ./samples_tests -v
run: go test ./samples_tests -v
8 changes: 8 additions & 0 deletions bin/configs/go-server-optional-body.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: go-server
outputDir: samples/server/others/go-server/optional-body
inputSpec: modules/openapi-generator/src/test/resources/3_0/optional_body.yaml
templateDir: modules/openapi-generator/src/main/resources/go-server
additionalProperties:
hideGenerationTimestamp: "true"
packageName: petstoreserver
addResponseHeaders: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
openapi: 3.0.3
info:
title: optional body
version: 1.0.1
servers:
- url: https://api.123.com/api/v1
tags:
- name: just-api
description: Everything about API functions
paths:
/silly:
post:
tags:
- just-api
operationId: send_optional_payload
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Payload"
responses:
'200':
description: Successful operation
content:
application/text:
schema:
type: string
components:
schemas:
Payload:
type: object
properties:
token:
type: string
description: Some kind of token - usually received by Email
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Dockerfile
README.md
api/openapi.yaml
go.mod
go/api.go
go/api_just_api.go
go/api_just_api_service.go
go/error.go
go/helpers.go
go/impl.go
go/logger.go
go/model_payload.go
go/routers.go
main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.16.0-SNAPSHOT
15 changes: 15 additions & 0 deletions samples/server/others/go-server/optional-body/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.19 AS build
WORKDIR /go/src
COPY go ./go
COPY main.go .
COPY go.sum .
COPY go.mod .

ENV CGO_ENABLED=0

RUN go build -o petstoreserver .

FROM scratch AS runtime
COPY --from=build /go/src/petstoreserver ./
EXPOSE 8080/tcp
ENTRYPOINT ["./petstoreserver"]
35 changes: 35 additions & 0 deletions samples/server/others/go-server/optional-body/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Go API Server for petstoreserver

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: 1.0.1
- Generator version: 7.16.0-SNAPSHOT


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

```
go run main.go
```

The server will be available on `http://localhost:8080`.

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

Once image is built use
```
docker run --rm -it petstoreserver
```
37 changes: 37 additions & 0 deletions samples/server/others/go-server/optional-body/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: 3.0.3
info:
title: optional body
version: 1.0.1
servers:
- url: https://api.123.com/api/v1
tags:
- description: Everything about API functions
name: just-api
paths:
/silly:
post:
operationId: send_optional_payload
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Payload"
responses:
"200":
content:
application/text:
schema:
type: string
description: Successful operation
tags:
- just-api
components:
schemas:
Payload:
example:
token: token
properties:
token:
description: Some kind of token - usually received by Email
type: string
type: object
4 changes: 4 additions & 0 deletions samples/server/others/go-server/optional-body/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module github.com/GIT_USER_ID/GIT_REPO_ID

go 1.18

34 changes: 34 additions & 0 deletions samples/server/others/go-server/optional-body/go/api.go

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

102 changes: 102 additions & 0 deletions samples/server/others/go-server/optional-body/go/api_just_api.go

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

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

Loading
Loading