Skip to content

[Feature]: Allow values in @ExampleObject to be read from a file #5180

@shreyTech

Description

@shreyTech

Feature Description

I would like to see a way to define example payloads in the @ExampleObject annotation from a file, rather than declaring constants for it.

  • What problem does it solve?
    For APIs with larger payloads, defining payloads with @ExampleObjects becomes unmanageable because the examples must be defined as constants, resulting in boilerplate code in Java classes.
  • How would it improve swagger-core?
    It will make it easier to maintain large example payloads without creating constants in Java.
  • Is it related to OpenAPI spec support, annotation improvements, integration, etc.?
    It would be categorized as annotation improvement.

Use Case

@ExampleObject ( description = "test description", file = "classpath:/main/resources/openapi/test-example.json")

Suggested Solution (optional)

Add a feature in the @ExampleObject annotation to read a value from a file.

Alternatives Considered

Additional Context

Checklist

  • I have searched the existing issues to ensure this is not a duplicate.
  • This feature would be useful to more than just my use case.
  • I have provided enough detail for the maintainers to understand the scope of the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions