swagger-api / swagger-api/swagger-core

Custom UUID wrapper class can't be used anymore after 2.2.28

Open
#4,923 0 comments 0 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

We are using custom classes to represent different IDs for our entities to have type safety:

@Schema(type = "string", format = "uuid", example = "\"\\\"92c1fe60-02a9-4317-9a66-1e8031cfef43\\\"\"")
public class AccountUuid extends StrictUuid {
    private static final String JSON_NAME = "accountUuid";

    @JsonCreator
    public static AccountUuid accountUuid(@JsonProperty(JSON_NAME) String accountUuid) {
        return new AccountUuid(accountUuid);
    }

    public static AccountUuid random() {
        return accountUuid(randomUUID().toString());
    }

    private AccountUuid(String uuid) {
        super(uuid);
    }

    @Override
    @JsonProperty(JSON_NAME)
    public String get() {
        return super.get();
    }

    public static AccountUuid valueOf(String accountUuid) {
        return new AccountUuid(accountUuid);
    }
}

This has worked fine until version 2.2.28, but after upgrading to anything >= 2.2.29, we get the following error in our SwaggerUI:

swagger-ui-bundle.js:2 Error: Could not parse parameter value string as JSON Object or JSON Array
    at parseJsonObjectOrArray (swagger-ui-bundle.js:2:1081613)
    at swagger-ui-bundle.js:2:1086301
    at Array.forEach (<anonymous>)
    at Object.execute_buildRequest [as buildRequest] (swagger-ui-bundle.js:2:1085597)
    at swagger-ui-bundle.js:2:687925
    at swagger-ui-bundle.js:2:543649
    at swagger-ui-bundle.js:2:539731
    at swagger-ui-bundle.js:2:692220
    at Object.newAction (swagger-ui-bundle.js:2:552088)
    at Object.executeRequest (swagger-ui-bundle.js:2:555884)

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 Swagger UI failure with the custom Java AccountUuid wrapper, comparing version 2.2.28 with 2.2.29 or later. Inspect the generated parameter value and the Swagger UI request parsing path; done means the custom UUID can again be used successfully in Swagger UI without the JSON parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.