OpenAPITools / OpenAPITools/openapi-generator

[BUG] warning for optional attribte spams build log with "Empty operationId found for path"

Open
#9,630 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generating code from specification with many operations may lead to build-log spamming with messages like:

[WARNING] Empty operationId found for path: get /{realm}/users/count. Renamed to auto-generated operationId: realmUsersCountGet
[WARNING] Empty operationId found for path: get /{realm}/users/{id}. Renamed to auto-generated operationId: realmUsersIdGet
[WARNING] Empty operationId found for path: put /{realm}/users/{id}. Renamed to auto-generated operationId: realmUsersIdPut
[WARNING] Empty operationId found for path: delete /{realm}/users/{id}. Renamed to auto-generated operationId: realmUsersIdDelete

In the case of https://github.com/ccouzens/keycloak-openapi/blob/main/keycloak/12.0-patched.json this would be 290 Warnings.

Now operationId is an optional attribte, and omitting an optional attribute should not lead to a warning in the build log, but to either silent usage of the auto-generated operationId, or an informative log-statement or one for debugging purposes. In this case, even the log-level "debug" would spam the build-log with an extreme amount of lines.

This is why I would recommend removal of the logging statement. See https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L4639

openapi-generator version

5.0.1

OpenAPI declaration file content or url

https://github.com/ccouzens/keycloak-openapi/blob/main/keycloak/12.0-patched.json

Generation Details
<configuration>
    <!-- only generate api operations wih given tags -->
    <apisToGenerate>Users</apisToGenerate>
    <!-- only generate models that are referenced in generated api operations -->
    <modelsToGenerate>CredentialRepresentation,FederatedIdentityRepresentation,UserConsentRepresentation,UserRepresentation,UserSessionRepresentation,GroupRepresentation</modelsToGenerate>
    <inputSpec>${project.basedir}/src/main/resources/idp/12.0-patched.json</inputSpec>
    <generatorName>jaxrs-spec</generatorName>
    <output>${project.build.directory}/generated-sources/openapi/keycloak</output>
    <configOptions>
        <useTags>true</useTags>
        <interfaceOnly>true</interfaceOnly>
        <returnResponse>false</returnResponse>
        <sourceFolder>java</sourceFolder>
        <useSwaggerAnnotations>false</useSwaggerAnnotations>
        <generatePom>false</generatePom>
        <dateLibrary>java8</dateLibrary>
    </configOptions>
</configuration>
Steps to reproduce

Generate code from https://github.com/ccouzens/keycloak-openapi/blob/main/keycloak/12.0-patched.json
I suspect that any generator will lead to the same logging behaviour.

Related issues/PRs

Not for OpenAPI, but for swagger-codegen: https://github.com/swagger-api/swagger-codegen/issues/5162

Suggest a fix

Delete the mentioned log statement.

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.

Research direction

Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java around line 4639, then reproduce generation with the linked Keycloak OpenAPI document or a smaller spec containing operations without operationId. Check the generator's logging behavior and relevant tests; done means omitted optional operationIds no longer produce build-log warnings while generated operationIds still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.