Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pjfanning/swagger-akka-http-sample
Sample demonstrating use of swagger-akka-http
https://github.com/pjfanning/swagger-akka-http-sample
akka akka-http enumeratum openapi scala swagger swagger-akka-http
Last synced: 10 days ago
JSON representation
Sample demonstrating use of swagger-akka-http
- Host: GitHub
- URL: https://github.com/pjfanning/swagger-akka-http-sample
- Owner: pjfanning
- License: apache-2.0
- Created: 2016-02-03T03:31:36.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-02-15T13:41:13.000Z (9 months ago)
- Last Synced: 2024-10-14T11:27:19.065Z (23 days ago)
- Topics: akka, akka-http, enumeratum, openapi, scala, swagger, swagger-akka-http
- Language: Scala
- Homepage:
- Size: 187 KB
- Stars: 84
- Watchers: 7
- Forks: 45
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# swagger-akka-http-sample
Check out this git repo and use `sbt run` to start the Akka Http server.
Uses [swagger-akka-http](https://github.com/swagger-akka-http/swagger-akka-http) which is built using [swagger.io](http://swagger.io/) libs.
Test using the Swagger UI at http://localhost:12345/api-docs. You can view the swagger doc itself at http://localhost:12345/api-docs/swagger.json and http://localhost:12345/api-docs/swagger.yaml.
The [Swagger UI](https://swagger.io/tools/swagger-ui/) can be used to send sample requests.
http://localhost:12345/api-docs redirects to https://petstore.swagger.io/ but provides a 'url' parameter that causes this sample's swagger.json to be loaded.
[Swagger 1.5/1.6 version](https://github.com/pjfanning/swagger-akka-http-sample/tree/swagger-1.5)
## Current swagger.json
```
{
"openapi" : "3.0.1",
"info" : {
"title" : "",
"description" : "",
"termsOfService" : "",
"version" : "1.0"
},
"externalDocs" : {
"description" : "Core Docs",
"url" : "http://acme.com/docs"
},
"servers" : [ {
"url" : "http://localhost:12345"
} ],
"security" : [ ],
"paths" : {
"/add" : {
"post" : {
"summary" : "Add integers",
"description" : "Add integers",
"operationId" : "add",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/AddRequest"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Add response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/AddResponse"
}
}
}
},
"500" : {
"description" : "Internal server error"
}
}
}
},
"/addOption" : {
"post" : {
"summary" : "Add integers",
"description" : "Add integers",
"operationId" : "addOption",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/AddOptionRequest"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Add response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/AddOptionResponse"
}
}
}
},
"500" : {
"description" : "Internal server error"
}
}
}
},
"/echoenum" : {
"post" : {
"summary" : "Echo Enum",
"description" : "Echo Enum",
"operationId" : "echo",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoEnum"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Echo Enum",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoEnum"
}
}
}
},
"400" : {
"description" : "Bad Request"
}
}
}
},
"/echoenumeratum" : {
"post" : {
"summary" : "Echo Enumeratum",
"description" : "Echo Enumeratum",
"operationId" : "echo_1",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoEnumeratum"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Echo Enumeratum",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoEnumeratum"
}
}
}
},
"400" : {
"description" : "Bad Request"
}
}
}
},
"/echolist" : {
"post" : {
"summary" : "Echo List",
"description" : "Echo List",
"operationId" : "echo_2",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoList"
}
}
},
"required" : true
},
"responses" : {
"200" : {
"description" : "Echo List",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/EchoList"
}
}
}
},
"400" : {
"description" : "Bad Request"
}
}
}
},
"/hello" : {
"get" : {
"summary" : "Return Hello greeting (anonymous)",
"description" : "Return Hello greeting for anonymous request",
"operationId" : "getHello",
"responses" : {
"200" : {
"description" : "Hello response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Greeting"
}
}
}
},
"500" : {
"description" : "Internal server error"
}
}
}
},
"/hello/{name}" : {
"get" : {
"summary" : "Return Hello greeting",
"description" : "Return Hello greeting for named user",
"operationId" : "getHelloSegment",
"parameters" : [ {
"name" : "name",
"in" : "path",
"description" : "user name",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "Hello response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Greeting"
}
}
}
},
"500" : {
"description" : "Internal server error"
}
}
}
}
},
"components" : {
"schemas" : {
"AddRequest" : {
"required" : [ "numbers" ],
"type" : "object",
"properties" : {
"numbers" : {
"type" : "array",
"items" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"SeqString" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"Greeting" : {
"required" : [ "greeting" ],
"type" : "object",
"properties" : {
"greeting" : {
"type" : "string"
}
}
},
"EchoList" : {
"required" : [ "listName", "values" ],
"type" : "object",
"properties" : {
"listName" : {
"type" : "string"
},
"values" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
},
"AddOptionResponse" : {
"required" : [ "sum" ],
"type" : "object",
"properties" : {
"sum" : {
"type" : "integer",
"format" : "int32"
}
}
},
"AddOptionRequest" : {
"required" : [ "number" ],
"type" : "object",
"properties" : {
"number" : {
"type" : "integer",
"format" : "int32"
},
"number2" : {
"type" : "integer",
"format" : "int32"
}
}
},
"EchoEnumeratum" : {
"required" : [ "enumValue" ],
"type" : "object",
"properties" : {
"enumValue" : {
"type" : "string",
"enum" : [ "TALL", "GRANDE", "VENTI" ]
}
}
},
"EchoEnum" : {
"required" : [ "enumValue" ],
"type" : "object",
"properties" : {
"enumValue" : {
"type" : "string",
"enum" : [ "TALL", "GRANDE", "VENTI" ]
}
}
},
"AddResponse" : {
"required" : [ "sum" ],
"type" : "object",
"properties" : {
"sum" : {
"type" : "integer",
"format" : "int32"
}
}
}
}
}
}
```