Skip to content

Commit b136c46

Browse files
dkrasnoffnikpachoo
authored andcommitted
Added swagger
1 parent 2c83675 commit b136c46

File tree

4 files changed

+27
-99
lines changed

4 files changed

+27
-99
lines changed

README.md

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -52,103 +52,7 @@ remove [aws-serverless-container](https://github.com/awslabs/aws-serverless-java
5252

5353
## API Documentation :page_with_curl:
5454

55-
### Execute Kotlin code on JVM
56-
57-
```shell script
58-
curl -X POST \
59-
http://localhost:8080/api/compiler/run \
60-
-H 'Content-Type: application/json' \
61-
-d '{
62-
"args": "1 2 3",
63-
"files": [
64-
{
65-
"name": "File.kt",
66-
"text": "fun main() {\n println(\"123\")\n}"
67-
}
68-
]
69-
}'
70-
```
71-
72-
### Translate Kotlin code to JavaScript code
73-
74-
```shell script
75-
curl -X POST \
76-
http://localhost:8080/api/compiler/translate \
77-
-H 'Content-Type: application/json' \
78-
-d '{
79-
"args": "1 2 3",
80-
"files": [
81-
{
82-
"name": "File.kt",
83-
"text": "fun main(args: Array<String>) {\n println(args[0])\n }"
84-
}
85-
]
86-
}'
87-
```
88-
89-
### Run Kotlin tests
90-
91-
```shell script
92-
curl -X POST \
93-
http://localhost:8080/api/compiler/test \
94-
-H 'Content-Type: application/json' \
95-
-d '{
96-
"files": [
97-
{
98-
"name": "File.kt",
99-
"text": "fun start(): String = \"OK\""
100-
},
101-
{
102-
"name": "test0.kt",
103-
"text": "import org.junit.Assert\nimport org.junit.Test\n\nclass TestStart {\n @Test fun testOk() {\n Assert.assertEquals(\"OK\", start())\n }\n}"
104-
},
105-
{
106-
"name": "test1.kt",
107-
"text": "package koans.util\n\nfun String.toMessage() = \"The function '\''$this'\'' is implemented incorrectly\"\n\nfun String.toMessageInEquals() = toMessage().inEquals()\n\nfun String.inEquals() = this"
108-
}
109-
]
110-
}'
111-
```
112-
113-
### Get code completions for a specified place in code
114-
115-
```shell script
116-
curl -X POST \
117-
'http://localhost:8080/api/compiler/complete?line=2&ch=15' \
118-
-H 'Content-Type: application/json' \
119-
-d '{
120-
"files": [
121-
{
122-
"name": "File.kt",
123-
"text": "fun main() {\n val sinusoid = \"sinusoid\"\n val s = sin\n}"
124-
}
125-
]
126-
}'
127-
```
128-
129-
### Get code analysis results
130-
131-
```shell script
132-
curl -X POST \
133-
http://localhost:8080/api/compiler/highlight \
134-
-H 'Content-Type: application/json' \
135-
-d '{
136-
"files": [
137-
{
138-
"name": "File.kt",
139-
"text": "fun main() {\n println(\"Hello, world!!!\")ass\n val random = Random\n}"
140-
}
141-
]
142-
}'
143-
```
144-
145-
### Get the current Kotlin version
146-
147-
```shell script
148-
curl -X GET http://localhost:8080/versions
149-
```
150-
151-
The server also supports an [API](https://github.com/JetBrains/kotlin-playground) for the Kotlin Playground library.
55+
Swagger url: http://localhost:8080/swagger-ui/
15256

15357
## How to add your dependencies to kotlin compiler :books:
15458

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ dependencies {
5959
annotationProcessor("org.springframework:spring-context-indexer")
6060
implementation("com.google.code.gson:gson")
6161
implementation("org.springframework.boot:spring-boot-starter-web")
62+
implementation("io.springfox:springfox-boot-starter:3.0.0")
6263
implementation("com.amazonaws.serverless:aws-serverless-java-container-springboot2:1.9.3")
6364
implementation("junit:junit:4.13.2")
6465
implementation("net.logstash.logback:logstash-logback-encoder:7.3")

executors/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
plugins {
@@ -11,8 +12,8 @@ dependencies {
1112
}
1213

1314
tasks.withType<KotlinCompile> {
14-
kotlinOptions {
15-
jvmTarget = "17"
15+
compilerOptions {
16+
jvmTarget.set(JvmTarget.JVM_17)
1617
}
1718
}
1819

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.compiler.server.configuration
2+
3+
import com.compiler.server.controllers.CompilerRestController
4+
import org.springframework.context.annotation.Bean
5+
import org.springframework.context.annotation.Configuration
6+
import springfox.documentation.builders.PathSelectors
7+
import springfox.documentation.builders.RequestHandlerSelectors
8+
import springfox.documentation.spi.DocumentationType
9+
import springfox.documentation.spring.web.plugins.Docket
10+
11+
@Configuration
12+
class SwaggerConfiguration {
13+
@Bean
14+
fun apiDocket(): Docket {
15+
return Docket(DocumentationType.OAS_30)
16+
.select()
17+
// If controllers are in different packages we should add selectors for these packages as well
18+
.apis(RequestHandlerSelectors.basePackage(CompilerRestController::class.java.packageName))
19+
.paths(PathSelectors.any())
20+
.build()
21+
}
22+
}

0 commit comments

Comments
 (0)