Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExampleValues annotation for schema generation along with date examples #5088

Merged

Conversation

dlvenable
Copy link
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
Member Author

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

assertThat(propertyNode.get("examples").get(1).get("description").getNodeType(), equalTo(JsonNodeType.STRING));
assertThat(propertyNode.get("examples").get(1).get("description").textValue(), equalTo("This is the second value."));
}

@JsonClassDescription("test config")
static class TestConfig {
@JsonPropertyDescription("The aggregate action description")
Copy link
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
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
Contributor

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
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
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
46 of 47 checks passed
@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