OpenAPITools / OpenAPITools/openapi-generator

Swagger Annotations: Who Are They For?

Open
#5,303 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

While looking at cleaning up dependencies for my generated models, I saw that swagger annotations are always imported and would require a code change to exclude from imports. My question is: why is this a feature at all?

https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations

My understanding of these annotations is that their main purpose is to support a code first style of programming - i.e. where you use your own hand coded models with these annotations to generate a spec for consumers. But with codegen we are using design first programming. The spec is your input, not your output. So why would I ever need swagger annotations put on a model that is being generated from a spec that already exists?

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 generated-model import behavior described in the issue and read the linked Swagger 2.X annotations documentation. Determine whether annotations are required for generated models and define the desired exclusion behavior before making any change; no file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.