swagger-api / swagger-api/swagger-codegen

swagger-codegen generate should error out on invalid spec - invalid field name

Open
#5,160 0 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

swagger-codegen generate should error out on invalid spec - invalid field name

Description

Notice the invalid descripion. This affects definitions as well.

Looks like pretty much everything is affected. Besides common typos, I often run into this in cases where $ref: ... is expected but I accidentally entered schema: {$ref: ...

Swagger-codegen version

current master; HEAD = 1c160df33897898da1c39f230c737eb6a313e6ba

Swagger declaration file content or url
swagger: '2.0'

info:
  title: "sscce"
  version: '1.0'
  description: sscce

paths:
  /foo:
    post:
      descripion: foo
      responses:
        "200":
          description: foo
          type: string
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 html2 -o foo

Probably target independent, had same issues with html

Steps to reproduce
Related issues
Suggest a Fix

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 running the supplied swagger-codegen CLI command with the YAML declaration containing the misspelled descripion field. Trace where the specification is parsed and validated, then confirm that generation stops with an error for invalid fields in operations and definitions rather than proceeding silently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
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.