swagger-api / swagger-api/swagger-codegen

Valid YAML Alias/Anchor features not supported fy Jackson

Open
#9,156 1 comment 1 reaction 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

Description

YAML have so called Aliases/Anchors &/*. If I use them in swagger 3 project I got exception, cause Alias/Anchor feature was skipped. Its not directly Swagger issue, its seems Jackson. But you could switch YAML parsing library to any other. Btw. I didnt had this issue in Swagger 2.
Heres Jackson issue:
https://github.com/FasterXML/jackson-dataformats-text/issues/98

Swagger-codegen version

3.0.4

Swagger declaration file content or url
paths:
  /marketplaces/{marketplaceId}/claims:
    get:
      tags:
        - 'claims'
      summary: get Claims list
      operationId: getClaims
      parameters:
        - &marketplaceId
          name: marketplaceId
          in: path
          description: 'marketplaceId: darty, amazon-fr, amazon-de, amazon-com'
          required: true
          schema:
            type: string
  /marketplaces/{marketplaceId}/claims/{claimId}/messages:
    post:
      tags:
        - 'claims'
      summary: post Claim message
      operationId: postClaimMessage
      parameters:
        - *marketplaceId
        - name: claimId
          in: path
          required: true
          schema:
            type: string

Command line used for generation

It doesnt metter. It generic YAML processing issue. generate something

Steps to reproduce
  1. generate any code from my yaml
  2. You will get java.util.NoSuchElementException: No value present
Related issues/PRs
Suggest a fix/enhancement

Use another YAML parsing lib. From Jackson bug comments I see snakeyaml process this without problem

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 by reproducing the NoSuchElementException with the YAML declaration in the report using swagger-codegen 3.0.4, then trace the generic YAML parsing entry point and compare the behavior with the linked Jackson issue. Check whether the proposed SnakeYAML alternative handles the anchor and alias; done means valid YAML with those features generates successfully.

Written by the indexing model from the issue text.

Assessment

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