swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.01k stars 6.03k forks source link

[JAVA] Unable to access generated API threw HTTP, help needed! #9042

Open gillesvz opened 5 years ago

gillesvz commented 5 years ago
Description

Using RESTEasy export from SwaggerHub of my OpenAPI 3.0 project, I can't access to the API ressources threw HTTP after running the application.

Swagger-codegen version

SwaggerHub codegen current version

Swagger declaration
openapi: 3.0.0
servers:
# Added by API Auto Mocking Plugin
  - description: SwaggerHub API Auto Mocking
    url: http://localhost:8080
info:
  description: This is a TTS & STT API
  version: "1.0.0"
  title: Simple TTS & STT API
  contact:
    email: support@company.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
  - name: admins
    description: Secured Admin-only calls
  - name: developers
    description: Operations available to regular developers
paths:
  /TextToSpeech:
    get:
      summary: text to speech
      operationId: TextToSpeech
      description: text to speech
      parameters:
        - in: query
          name: inputText
          description: text to analyze
          required: true
          schema:
            type: string
        - in: query
          name: lang
          description: origin langage
          required: true
          schema:
            type: string
      responses:
        '200':
          description: returned speech
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Speech'
        '400':
          description: bad input parameter
  /SpeechToText:
    post:
      summary: speech to text
      operationId: SpeechToText
      description: speech to text
      responses:
        '201':
          description: returned text
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Text'
        '400':
          description: 'invalid input, object invalid'
      requestBody:
        content:
          application/octet-stream:
            schema:
              $ref: '#/components/schemas/Speech'
        description: original speech
components:
  schemas:
    Speech:
      type: string
      format: binary
    Text:
      required:
        - name
      properties:
        inputText:
          type: string
          example: can you help me with my last order?
        lang:
          type: string
          example: 'en-US'
      type: object
Steps to reproduce
frantuma commented 5 years ago

assuming you have used server generator jaxrs-resteasy, its war can be deployed as is e.g. to wildfly; to have it work in Tomcat it would need to have pom.xml and possibly web.xml tweaked to add missing dependencies and config. Alternatively you could use jaxrs-resteasy-eap generator, which provides a stub executable directly via jetty (mvn package jetty:run) or deployed in others app server like Tomcat.

gillesvz commented 5 years ago

Grazzie mille Francesco! The only one I haven't tried works perfectly. I'm currious to know more about this "missing config" the web.xml needs and where the community can find it. Thanks for your help