swagger-api / swagger-api/swagger-parser

Poor error message on incorrectly written inheritance: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'swagger': was expecting ('true', 'false' or 'null')

Open
#424 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Redirected here from https://github.com/swagger-api/swagger-codegen/issues/5080

Description

Poor error message on incorrectly written inheritance: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'swagger': was expecting ('true', 'false' or 'null')

Swagger-codegen version

current master; HEAD = 878b390ab6962cc7cf5a9f8f5dec836d109cd2c9

Swagger declaration file content or url
swagger: "2.0"

info:
  title: swagger-codegen broken error messages
  version: '1.0'

definitions:
  foo:
    type: object
    properties:
      x:
        type: string

  bar:
    allOf:
      $ref: "#/definitions/foo"
      type: object
      properties:
        y:
          type: string

paths: {}

Note the missing hyphens in front of $ref and type in the single occurence of allOf

Command line used for generation

JAR=".../swagger-codegen.git/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
java -jar "${JAR}" generate -i ~/sscce.yaml -l swagger

Related issues

Plenty, google Unrecognized token 'swagger': was expecting ('true', 'false' or 'null')

Suggest a Fix

invalid contents of allOf: on line {line} expected {expected} got {got} on line {line_no}

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 issue with the provided YAML declaration and the swagger-codegen CLI command, focusing on the malformed allOf entry where $ref and type lack list-item hyphens. Done means the parser reports the invalid allOf contents with the expected and received values and a line number, instead of the misleading JsonParseException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.