swagger-api / swagger-codegen-generators

Apache License 2.0
284 stars 420 forks source link

unable to run kotlin-server in Swagger 3.0 #252

Open manuchadha1979 opened 5 years ago

manuchadha1979 commented 5 years ago

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?

HugoMario commented 5 years ago

hello @manuchadha1979 going to check this and let you know.

manuchadha1979 commented 5 years ago

Hi

Could you please let me know if or by when this might get fixed?

Thanks Manu

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: HugoMario notifications@github.com Sent: Tuesday, December 4, 2018 6:43:38 PM To: swagger-api/swagger-codegen-generators Cc: manuchadha1979; Mention Subject: Re: [swagger-api/swagger-codegen-generators] unable to run kotlin-server in Swagger 3.0 (#252)

hello @manuchadha1979https://github.com/manuchadha1979 going to check this and let you know.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/swagger-api/swagger-codegen-generators/issues/252#issuecomment-444211137, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVr0w-LAcBd4pbHkfPok8jvjs1nGcIqUks5u1sJagaJpZM4ZBOi0.