swagger-api / swagger-api/swagger-codegen

Re-using enums with YAML anchor causing com.fasterxml.jackson.databind.node.TextNode cannot be cast to com.fasterxml.jackson.databind.node.ArrayNode

Open
#1,662 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi guys,

YAML anchors don't seem to be parsed correctly. I got the example from (https://github.com/swagger-api/swagger-editor/issues/609)

  swagger: '2.0'

  info:
    version: "0.0.1"
    title: API

  x-types:
    OperationType: &OperationType
      - registration

  paths:
    /checker:
      get:
        parameters:
          - name: operations
            in: query
            type: array
            items:
              type: string
              enum: *OperationType
            default: [registration]
        responses:
          200:
            description: OK
            schema:
              $ref: '#/definitions/OperationType'

  definitions:      
    OperationType:
      type: string
      enum: *OperationType

I tried to define the anchor in a different way - none of them works, giving me com.fasterxml.jackson.databind.node.TextNode cannot be cast to com.fasterxml.jackson.databind.node.ArrayNode

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

Reproduce the failure with the YAML example in the issue, focusing on the anchored enum used under parameters and definitions. Trace the OpenAPI parsing path that produces the Jackson TextNode-to-ArrayNode cast, then verify that the same document is accepted without that exception and that the enum remains usable in generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, yaml
Domain
api
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.