swagger-api / swagger-api/swagger-codegen-generators

unable to run kotlin-server in Swagger 3.0

Open
#252 2 comments 0 reactions 1 assignee View on GitHub

@HugoMario is already working on this.

Since Dec 4, 2018.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

I am unable to run the kotlin-server generated by Swagger editor. I am on Windows machine

The .yaml file is

openapi: 3.0.0
info:
  title: Experiement with Swagger
  description: Test
  version: 1.0.0
servers:
  - url: 'http://localhost:8080'
    description: production server's url
tags:
  - name: Test
    description: Test
    externalDocs:
      description: Find out more
      url: 'http://localhost:8080'
paths:
  /testURI:
    post:
      tags:
        - Test
      summary: Test
      description: Test
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Test'
      responses:
        '200':
          description: Test success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestSuccessResponse'
        '404':
          description: >-
            Only a signed in user can add a question. This response means that
            the user isn't signed in.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorisedErrorResponse'
        '500':
          description: >-
            means some internal error occur on the server while doing the
            operation. The state of the operation if un-determined and the
            operation could be succesful, failed or partially successful
            (because some database operations are not rolled back if error
            occurs!
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'


components:
  schemas:
    Test:
      type: object
      properties:
        some-input:
          type: string

    TestSuccessResponse:
      type: object
      properties:
        result:
          type: string
          enum:
            - success
        additional-info:
          type: string
          enum:
            - Test successful
      required:
        - result
        - additional-info
    UnauthorisedErrorResponse:
      type: object
      properties:
        result:
          type: string
          enum:
            - error
        additional-info:
          type: string
          enum:
            - Not authorised
      required:
        - result
        - additional-info
    InternalServerErrorResponse:
      type: object
      properties:
        result:
          type: string
          enum:
            - error
        additional-info:
          type: string
          enum:
            - Internal Server Error
      required:
        - result
        - additional-info

I downloaded the kotlin-server-server-generated.zip, unzipped it at C:\Users\manu\Documents\manu\kotlin-server-server-generated, opened Readme.MD file and followed the instructions in it.

Using Windows cmd, In C:\Users\manu\Documents\manu\kotlin-server-server-generated,
first I ran gradle wrapper

I got this output

Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
Build cache is an incubating feature.

BUILD SUCCESSFUL in 17s
1 actionable task: 1 executed

Then I ran gradlew check assemble

C:\Users\manu\Documents\manu\kotlin-server-server-generated>gradlew check assemble
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
Build cache is an incubating feature.
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (51, 9): Variable 'gson' is never used
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (52, 9): Variable 'empty' is never used

> Task :startShadowScripts
Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead.


BUILD SUCCESSFUL in 36s
10 actionable tasks: 10 executed

Then I ran java -jar ./build/libs/kotlin-server.jar

2018-12-04 18:15:24.129 [main] TRACE Application - {
    # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 9
    "application" : {
        # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 10
        "modules" : [
            # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 10
            "io.swagger.server.AppMainKt.main"
        ]
    },
    # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 2
    "deployment" : {
        # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 5
        "autoreload" : true,
        # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 3
        "environment" : "development",
        # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 4
        "port" : 8080,
        # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 6
        "watch" : [
            # application.conf @ jar:file:/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar!/application.conf: 6
            "io.swagger.server"
        ]
    },
    # Content hidden
    "security" : "***"
}

2018-12-04 18:15:24.400 [main] DEBUG Application - Java Home: C:\Program Files\Java
2018-12-04 18:15:24.415 [main] DEBUG Application - Class Loader: sun.misc.Launcher$AppClassLoader@5c647e05: [/C:/Users/manu/Documents/manu/kotlin-server-server-generated/build/libs/kotlin-server.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/access-bridge-64.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/cldrdata.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/dnsns.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/jaccess.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/jfxrt.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/localedata.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/nashorn.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/sunec.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/sunjce_provider.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/sunmscapi.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/sunpkcs11.jar, /C:/Program%20Files/Java/jre1.8.0_191/lib/ext/zipfs.jar]
2018-12-04 18:15:24.415 [main] INFO  Application - No ktor.deployment.watch patterns match classpath entries, automatic reload is not active
2018-12-04 18:15:34.793 [metrics-logger-reporter-1-thread-1] INFO  Application - type=GAUGE, name=jvm.attributes.name, value=3948@WINDELL-5GEP3KO

But when I pointed the browser to localhost:8080, I see Page Not Found.

I even tried running kotlin-server.bat directly in CMD but got error Error: Could not find or load main class io.ktor.server.netty.DevelopmentEngine

What am I doing wrong?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.