swagger-api / swagger-api/swagger-core

Question: Is there a way to specify allowableValues dynamically?

Open
#3,567 4 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Hello,

Is there any way to provide allowableValues() for annotation Parameter dynamically (e.g from property file or DB)?

    @Operation(summary = "Retrieve a list of entities")
    @GetMapping
    public List<Entity> get(@Parameter(schema = @Schema(allowableValues = "OneOfThePossibleValuesOfEnum")) EntityTypeEnum entityType) {
...
}

In this example, I would like to have in the documentation, not all values or listed there but being able to populate them from another resource.

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 reviewing the @Parameter and @Schema annotations and the OpenAPI generation path mentioned in the issue. Determine whether allowable values can be sourced dynamically from a property file or database, and define the supported behavior and documentation outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Feature
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.