OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.82k stars 6.58k forks source link

[BUG][spring] -Dapis requires title-cased tags, even when tags are lowercase #5591

Open jimschubert opened 4 years ago

jimschubert commented 4 years ago

Bug Report Checklist

Description

This may be related only to Spring generator.

If a user has a tag defined as devices, the user will have to request -Dapis=Devices (or <apis>Devices</apis> in Maven). This isn't intuitive.

This was found by a user in Slack. I repro'd with:

<configuration>
    <inputSpec>lukas.yml</inputSpec>
    <generatorName>spring</generatorName>
    <configOptions>
        <sourceFolder>/</sourceFolder>
        <modelPackage>org.openapi.tools.model</modelPackage>
        <apiPackage>org.openapi.tools.api</apiPackage>
        <interfaceOnly>true</interfaceOnly>
        <java8>true</java8>
        <dateLibrary>java8</dateLibrary>
        <booleanGetterPrefix>is</booleanGetterPrefix>
        <useTags>true</useTags>
    </configOptions>
    <environmentVariables>
        <apis>Devices</apis>
    </environmentVariables>
</configuration>
openapi-generator version

4.3.0-SNAPSHOT (as of today) and below

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: "Java template service"
  description: "Example of java microservice API defined with OpenApi v3"
  version: 1.0.0
tags:
  - name: devices
    description: Box devices
paths:
  '/api/devices':
    get:
      tags:
        - devices
      operationId: "getDevices"
      summary: List of devcies
      description: Devices
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Device"

components:
  schemas:
    Device:
      required:
        - "id"
        - "mac"
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          example: "EF41860F-68AD-4ABE-8D6F-3734EDDE3017"
        mac:
          type: string
          format: mac_address
          readOnly: true
          example: "112233445566"
        online:
          type: boolean
          readOnly: true
          default: false
          example: false
Command line used for generation
Steps to reproduce

Copied above maven config into maven example java-client.xml and ran.

Related issues/PRs
Suggest a fix

Support both title and lower cases.

auto-labeler[bot] commented 4 years ago

šŸ‘ Thanks for opening this issue! šŸ· I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

cachescrubber commented 4 years ago

Have you checked the Config Option useTags? It defaults to false, which has an impact on theway apis or apisToGenerate are evaluated. Maybe it is not really a Bug but more so a documentation Issue.

arburk commented 1 year ago

We faced the same issue for

<generatorName>java</generatorName>
<library>resttemplate</library>

Using title-cased tag name solved the issue. Apparently this is a bug in the generator-api