OpenAPITools / OpenAPITools/openapi-generator

[BUG][GRADLE] Gradle 7.2 openApiGenerate task not working due to jackson tried to access private field

Open
#10,609 3 comments 0 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

I had a simple openApiGenerate task working.
I tried to upgrade my gradle version from 6.8.3 to 7.2 and also the org.openapi.generator gradle plugin version from 5.0.0 to 5.2.1

Error message :

class com.fasterxml.jackson.core.JsonFactoryBuilder tried to access private field com.fasterxml.jackson.core.JsonFactory.DEFAULT_ROOT_VALUE_SEPARATOR

Full error message :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ui:openApiGenerate'.
> class com.fasterxml.jackson.core.JsonFactoryBuilder tried to access private field com.fasterxml.jackson.core.JsonFactory.DEFAULT_ROOT_VALUE_SEPARATOR (com.fasterxml.jackson.core.JsonFactoryBuilder is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @7b10fbc7; com.fasterxml.jackson.core.JsonFactory is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @64659ab0)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 38s
openapi-generator version

On version 5.0.0 I got an annotation issue that has already been fixed.
Upgraded to version 5.2.1 I got the new jackson error.

OpenAPI declaration file content or url

build.gradle configuration

openApiGenerate {
  generatorName = "typescript-angular"
  inputSpec = "$projectDir/openapi/schema.yaml".toString()
  outputDir = "$projectDir/src/api".toString()
}

schema.yml openapi schema

---
openapi: 3.0.3
info:
  title: Generated API
  version: "1.0"
paths:
  /api/deployment:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeploymentEvent'
      responses:
        "201":
          description: Created
  /api/deployment/stream:
    get:
      responses:
        "200":
          description: OK
          content:
            text/event-stream:
              schema:
                $ref: '#/components/schemas/PublisherDeploymentEvent'
  /api/ticket:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TicketUpdateEvent'
      responses:
        "201":
          description: Created
  /api/ticket/stream:
    get:
      responses:
        "200":
          description: OK
          content:
            text/event-stream:
              schema:
                $ref: '#/components/schemas/PublisherTicketUpdateEvent'
components:
  schemas:
    DeploymentEvent:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
        description:
          type: string
        tags:
          type: array
          items:
            type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        deploymentType:
          $ref: '#/components/schemas/DeploymentType'
        deploymentStatus:
          $ref: '#/components/schemas/DeploymentStatus'
        applicationVersion:
          type: string
        environment:
          type: string
        application:
          type: string
    DeploymentStatus:
      enum:
      - FAILED
      - STARTED
      - SUCCESS
      type: string
    DeploymentType:
      enum:
      - ENVIRONMENT
      - PLATFORM
      type: string
    FieldUpdate:
      type: object
      properties:
        operation:
          $ref: '#/components/schemas/Operation'
        field:
          type: string
        value:
          type: string
    Metadata:
      type: object
    Operation:
      enum:
      - ADD
      - REMOVE
      - SET
      - UNSET
      type: string
    PublisherDeploymentEvent:
      type: object
    PublisherTicketUpdateEvent:
      type: object
    RequestType:
      enum:
      - FAILED
      - PROCESSED
      - REQUEST
      type: string
    System:
      enum:
      - JIRA
      type: string
    TicketUpdateEvent:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
        description:
          type: string
        tags:
          type: array
          items:
            type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        system:
          $ref: '#/components/schemas/System'
        identifier:
          type: string
        updates:
          type: array
          items:
            $ref: '#/components/schemas/FieldUpdate'
        requestType:
          $ref: '#/components/schemas/RequestType'

Steps to reproduce

graldew openApiGenerate

Related issues/PRs

I found the same error message in : https://github.com/OpenAPITools/openapi-generator/issues/5004

Suggest a fix

Fix looks like to be on Jackson libs dependencies.

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 with the build.gradle openApiGenerate configuration and the Gradle plugin versions 5.2.1 and 7.2; reproduce the failure with the provided schema.yml using gradlew openApiGenerate. Trace the Jackson dependency versions involved in the JsonFactoryBuilder access error and compare with related issue #5004. Done means the task completes without this error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.