Skip to content

ExampleValues annotation for schema generation along with date examples#5088

Merged
dlvenable merged 2 commits intoopensearch-project:mainfrom
dlvenable:5077-examples-on-properties
Oct 23, 2024
Merged

ExampleValues annotation for schema generation along with date examples#5088
dlvenable merged 2 commits intoopensearch-project:mainfrom
dlvenable:5077-examples-on-properties

Conversation

@dlvenable
Copy link
Copy Markdown
Member

@dlvenable dlvenable commented Oct 20, 2024

Description

Introduces @ExampleValues annotation for schema and documentation generation.

  • Adds a new annotation @ExampleValues.
  • Updates the schema generation with an InstanceAttributeOverride to add the examples to the schemas.
  • Adds @ExampleValues annotations to the date processor.

Issues Resolved

Resolves #5077

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

chenqi0805
chenqi0805 previously approved these changes Oct 21, 2024
…ration.

Adds a new annotation ExampleValues. Updates the schema generation with an InstanceAttributeOverride to add the examples to the schemas. Adds ExampleValues to the date processor.

Signed-off-by: David Venable <dlv@amazon.com>
@dlvenable
Copy link
Copy Markdown
Member Author

@chenqi0805 , I had to rebase with main due to file conflicts.


@JsonClassDescription("test config")
static class TestConfig {
@JsonPropertyDescription("The aggregate action description")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make this description more generic

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for testing.

*
* @since 2.11
*/
@interface Example {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be an inner interface? As it is inner, at the time of specifying these example values it looks overly verbose

@ExampleValues({
                @ExampleValues.Example("some example value"),
                @ExampleValues.Example(value = "second example value", description = "This is the second value.")
        })

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually quite common for annotations that are coupled with their parent. You can add ExampleValues as a static import.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a revision that imports ExampleValues.Example.

…ProcessorConfig.

Signed-off-by: David Venable <dlv@amazon.com>
@dlvenable dlvenable requested a review from sb2k16 as a code owner October 23, 2024 15:20
@dlvenable dlvenable merged commit f10867f into opensearch-project:main Oct 23, 2024
@dlvenable dlvenable deleted the 5077-examples-on-properties branch October 23, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support examples in documentation

4 participants