AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-4361477

Franck Dervaux's questions

Martin Hope
Franck Dervaux
Asked: 2025-03-29 00:58:16 +0800 CST

Os modelos não são gerados quando apis específicas são selecionadas por meio do plug-in gradle

  • 5

Estou tentando gerar código Java a partir do seguinte exemplo de especificação OpenAPI

openapi: "3.0.3"
info:
  title: Demo API
  version: "1.0"
servers:
  - url: http://localhost:8080/api
    description: Local development server
tags:
  - name: Common
    description: Operations related to common functionalities. Define multiple tags to generate multiple Api classes.
  - name: Other
    description: To test generation of separate APIs
paths:
  /UM/{id}:
    get:
      tags:
        - Common
      description: Retrieve UM by ID
      operationId: GetUM
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
      responses:
        "200":
          description: UM
          content:
            application/json:
              schema: { }
        "404":
          description: UM not found
          content:
            text/plain:
              schema:
                type: string
  /UM:
    post:
      tags:
        - Common
      description: Create new UM
      operationId: CreateUM
      requestBody:
        required: true
        content:
          application/json:
            schema: { }
      responses:
        201:
          description: ID of the newly created UM
          content:
            text/plain:
              schema:
                type: string

  /palettes/{id}:
    get:
      tags:
        - Common
      operationId: getPalette # necessary to generate proper method name
      description: Retrieve a palette by its id
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Palette"
              examples:
                Default:
                  value:
                    id: 1
                    firstName: John
                    lastName: Doe
                    role: user
        "404":
          description: Palette not found
          content:
            text/plain:
              schema:
                type: string
  /palettes:
    get:
      tags:
        - Common
      operationId: listPalettes
      description: Returns the list of palettes
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Palette"

    put:
      tags:
        - Common
      operationId: createPalette # necessary to generate proper method name
      description: Creates a new palette
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/NewPalette"
      responses:
        "201":
          description: Created
          content:
            text/plain:
              schema:
                type: integer
        "400":
          description: Validation errors
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationError"
  /orders:
    put:
      tags:
        - Common
      operationId: sendOrder
      description: Sends a dummy order
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
  /otherresources:
    get:
      tags:
        - Other
      operationId: getOther # necessary to generate proper method name
      description: Example operation
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Palette"

components:
  schemas:
    ObjectType:
      type: string
      enum: [ ENGINE, SEAT ]
    Palette:
      type: object
      x-tags:
        - Common
      properties:
        id:
          type: integer
          description: The user ID
        firstName:
          type: string
          description: The user's first name
        lastName:
          type: string
          description: The palette's last name
          minLength: 1
          maxLength: 20
        role:
          $ref: "#/components/schemas/ObjectType"

    NewPalette:
      type: object
      properties:
        firstName:
          type: string
          description: The user's first name
        lastName:
          type: string
          description: The user's last name
          minLength: 1
          maxLength: 20
        role:
          $ref: "#/components/schemas/ObjectType"

    ValidationErrorField:
      properties:
        field:
          type: string
        message:
          type: string
        constraint:
          type: string
        value:
          type: string
      example:
        - field: name
          message: size must be between 1 and 20
          constraint: Size
          value: This is way toooooooo long a name!

    ValidationError:
      properties:
        status:
          type: string
        message:
          type: string
        errors:
          type: array
          $ref: "#/components/schemas/ValidationErrorField"
      example:
        - status: Bad Request
          message: Validation failed
          errors:
            - field: lastName
              message: size must be between 1 and 20
              constraint: Size
              value: This is wayyyyyy toooo loooooong

  securitySchemes:
    oidc:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/auth
          tokenUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/token
          refreshUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/token
          scopes:
            openid: OpenID Connect authentication
security:
  - oidc: [ ]

Estou construindo isso com a seguinte tarefa Gradle:

openApiGenerate {
    generatorName = 'jaxrs-spec'
    inputSpec = file(openapiSourcefile).absolutePath
    outputDir = file(openapiGeneratedSources).absolutePath
    apiPackage = "${apiPackageName}.controller"
    modelPackage = "${apiPackageName}.model"
    generateAliasAsModel = true
    verbose = true
    globalProperties = [
        'apis'  : project.ext.apisToGenerate,
        'models': 'true'
    ]
    configOptions = [
        interfaceOnly                           : 'true',
        singleContentTypes                      : 'true',
        useSingleRequestMethod                  : 'true',
        useSwaggerAnnotations                   : 'false',
        useTags                                 : 'true',
        dateLibrary                             : 'java8',
        library                                 : 'quarkus',
        useMicroProfileOpenAPIAnnotations       : 'true',
        additionalModelTypeAnnotations          : '@jakarta.validation.constraints.NotNull',
        useBeanValidation                       : 'true',
        useJakartaEe                            : 'true',
        disallowAdditionalPropertiesIfNotPresent: 'false',
        generateModelTests                      : 'false',
        generateModelDocumentation              : 'false',
        generateApiTests                        : 'false',
        generateApiDocumentation                : 'false',
        generateBuilders                        : 'true',
        modelPropertyNaming                     : 'original',
        returnResponse                          : 'true',
    ]
}

E a propriedade project.ext.apisToGenerate está definida como 'Common'. O problema que tenho é que os modelos não são gerados. Eles são gerados somente quando removo a seleção de apis para gerar. Mas preciso gerar apenas as apis para tags específicas.

Qualquer ajuda é bem-vinda.

Preciso listar explicitamente os modelos que preciso gerar na propriedade 'models'?

openapi-generator
  • 1 respostas
  • 17 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Reformatar números, inserindo separadores em posições fixas

    • 6 respostas
  • Marko Smith

    Por que os conceitos do C++20 causam erros de restrição cíclica, enquanto o SFINAE antigo não?

    • 2 respostas
  • Marko Smith

    Problema com extensão desinstalada automaticamente do VScode (tema Material)

    • 2 respostas
  • Marko Smith

    Vue 3: Erro na criação "Identificador esperado, mas encontrado 'import'" [duplicado]

    • 1 respostas
  • Marko Smith

    Qual é o propósito de `enum class` com um tipo subjacente especificado, mas sem enumeradores?

    • 1 respostas
  • Marko Smith

    Como faço para corrigir um erro MODULE_NOT_FOUND para um módulo que não importei manualmente?

    • 6 respostas
  • Marko Smith

    `(expression, lvalue) = rvalue` é uma atribuição válida em C ou C++? Por que alguns compiladores aceitam/rejeitam isso?

    • 3 respostas
  • Marko Smith

    Um programa vazio que não faz nada em C++ precisa de um heap de 204 KB, mas não em C

    • 1 respostas
  • Marko Smith

    PowerBI atualmente quebrado com BigQuery: problema de driver Simba com atualização do Windows

    • 2 respostas
  • Marko Smith

    AdMob: MobileAds.initialize() - "java.lang.Integer não pode ser convertido em java.lang.String" para alguns dispositivos

    • 1 respostas
  • Martin Hope
    Fantastic Mr Fox Somente o tipo copiável não é aceito na implementação std::vector do MSVC 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant Encontre o próximo dia da semana usando o cronógrafo 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor O inicializador de membro do construtor pode incluir a inicialização de outro membro? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský Por que os conceitos do C++20 causam erros de restrição cíclica, enquanto o SFINAE antigo não? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul O C++20 mudou para permitir a conversão de `type(&)[N]` de matriz de limites conhecidos para `type(&)[]` de matriz de limites desconhecidos? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann Como/por que {2,3,10} e {x,3,10} com x=2 são ordenados de forma diferente? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller O ponto e vírgula agora é opcional em condicionais bash com [[ .. ]] na versão 5.2? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench Por que um traço duplo (--) faz com que esta cláusula MariaDB seja avaliada como verdadeira? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng Por que `dict(id=1, **{'id': 2})` às vezes gera `KeyError: 'id'` em vez de um TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob: MobileAds.initialize() - "java.lang.Integer não pode ser convertido em java.lang.String" para alguns dispositivos 2024-03-20 03:12:31 +0800 CST

Hot tag

python javascript c++ c# java typescript sql reactjs html

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve