Skip to content

Commit

Permalink
Add first version of swagger documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Sep 26, 2023
1 parent 15770ca commit d8a7552
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<artifactId>ktor-server-content-negotiation-jvm</artifactId>
<version>${ktor.version}</version>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-swagger-jvm</artifactId>
<version>${ktor.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.ktor.server.plugins.contentnegotiation.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.plugins.swagger.*

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

Expand Down Expand Up @@ -47,5 +48,6 @@ fun Application.module() {
call.respond(result)
}
}
swaggerUI(path="openapi", swaggerFile = "openapi/documentation.yaml")
}
}
49 changes: 49 additions & 0 deletions src/main/resources/openapi/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
openapi: "3.0.3"
info:
title: "Load Flow Service API"
description: "An API that interacts with Powsybl"
version: "1.0.0"
servers:
- url: "http://0.0.0.0:8080"
paths:
/get-buses:
post:
operationId: getBuses
description: "Return all buses in the network"
requestBody:
description: "Form with network sent as file"
required: true
content:
multipart/form-data:
schema:
type: object
properties:
network:
type: string
format: binary
responses:
"200":
description: "List with all buses in the network"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Bus"


components:
schemas:
Bus:
type: object
properties:
id:
type: string
voltage:
type: double
angle:
type: double
activePower:
type: double
reactivePower:
type: double

0 comments on commit d8a7552

Please sign in to comment.