Skip to content

chore: put default properties of capabilities outside items #313

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

Merged

Conversation

n2h9
Copy link
Contributor

@n2h9 n2h9 commented May 1, 2025

Notes for Reviewers

This PR fixes #

Signed commits

  • Yes, I signed my commits.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @n2h9, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on improving the structure and default values within the Meshery schemas, specifically related to capabilities and relationship templates. The primary goal is to move default properties of capabilities outside of the items field in several JSON and YAML schema files. Additionally, a match_strategy_matrix is added to relationship templates to define how values at mutator/mutated paths should be matched.

Highlights

  • Capability Schema Restructuring: The capabilities schema in component_template.json, component_template.yaml, design_template.json, and design_template.yaml has been modified to move default properties outside the items field. This change provides a more direct and clear definition of default capability properties.
  • Relationship Template Enhancement: The relationship_template.json, relationship_template.yaml, design_template.json, design_template.yaml and typescript definition relationship.d.ts are updated to include a match_strategy_matrix within the from section. This addition allows for defining specific strategies for matching values at mutator/mutated paths, enhancing relationship definition flexibility.
  • OpenApi Schema Updates: The OpenApi schema definitions for ComponentOpenApiSchema.ts and DesignOpenApiSchema.ts are updated to reflect the changes in capability schema structure, ensuring consistency across the codebase. The EvaluationOpenApiSchema.ts and SchemasOpenApiSchema.ts are also updated to reflect the change from service mesh performance to cloud native performance.
  • Feature OpenApi Schema: A new OpenApi schema definition for FeatureOpenApiSchema.ts is added to define the structure for features and entitlements.
  • Subscription OpenApi Schema: The SubscriptionOpenApiSchema.ts is updated to change the description and operationId for getting subscriptions.

Changelog

Click here to see the changelog
  • schemas/constructs/v1alpha3/relationship_template.json
    • Added match_strategy_matrix property within the from.items section to define matching strategies.
  • schemas/constructs/v1alpha3/relationship_template.yaml
    • Added match_strategy_matrix property within the from.items section to define matching strategies.
  • schemas/constructs/v1beta1/component/component.json
    • Moved x-oapi-codegen-extra-tags and default properties outside the items field for capabilities.
  • schemas/constructs/v1beta1/component/component_template.json
    • Restructured the capabilities schema to define default properties directly as an array of capability objects, rather than within an items field.
  • schemas/constructs/v1beta1/component/component_template.yaml
    • Restructured the capabilities schema to define default properties directly as an array of capability objects, rather than within an items field.
  • schemas/constructs/v1beta1/design/design_template.json
    • Restructured the capabilities schema to define default properties directly as an array of capability objects, rather than within an items field.
    • Added match_strategy_matrix property within the from.items section to define matching strategies.
  • schemas/constructs/v1beta1/design/design_template.yaml
    • Restructured the capabilities schema to define default properties directly as an array of capability objects, rather than within an items field.
    • Added match_strategy_matrix property within the from.items section to define matching strategies.
  • typescript/constructs/v1alpha3/relationship.d.ts
    • Added match_strategy_matrix property to the HttpsSchemasMesheryIoRelationshipJson interface to define matching strategies.
  • typescript/constructs/v1beta1/component/ComponentOpenApiSchema.ts
    • Removed the default property from within the items field for capabilities.
    • Added default property outside the items field for capabilities.
    • Added default values for styling, shape, compound drag and drop, and body text.
  • typescript/constructs/v1beta1/design/DesignOpenApiSchema.ts
    • Removed the default property from within the items field for capabilities.
    • Added default property outside the items field for capabilities.
    • Added default values for styling, shape, compound drag and drop, and body text.
    • Added match_strategy_matrix property within the from.items section to define matching strategies.
  • typescript/constructs/v1beta1/feature/FeatureOpenApiSchema.ts
    • Added a new OpenApi schema definition for features and entitlements.
  • typescript/constructs/v1beta1/subscription/SubscriptionOpenApiSchema.ts
    • Updated the description and operationId for getting subscriptions.
  • typescript/mnt/space2/code/meshery/schemas/schemas/SchemasOpenApiSchema.ts
    • Changed service mesh performance to cloud native performance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A schema's design,
Can make code truly shine,
With defaults in place,
Elegance and grace,
A system that's truly divine.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR aims to refactor the structure of component capabilities and relationship templates in several schema files. The changes seem to be focused on improving the organization and flexibility of these schemas. However, there are some areas where the changes could be improved, such as removing redundant default values and ensuring consistency across different schema versions.

Summary of Findings

  • Schema updates: The PR updates several JSON and YAML schema files to modify the structure and default values of component capabilities and relationship templates. The key change involves moving default properties of capabilities outside of the items field in component and design templates, and adding a match_strategy_matrix to relationship templates.
  • TypeScript definitions: The TypeScript definitions are updated to reflect the changes in the JSON schemas, particularly the addition of match_strategy_matrix in the HttpsSchemasMesheryIoRelationshipJson interface.
  • Redundant default values in ComponentOpenApiSchema.ts: The ComponentOpenApiSchema.ts file contains redundant default values for capabilities. These default values are defined at multiple places, which can lead to inconsistencies and maintenance issues.

Merge Readiness

The pull request is not yet ready for merging. The redundant default values in ComponentOpenApiSchema.ts should be addressed to avoid potential inconsistencies. Additionally, the high severity comment about the removal of default values in the same file needs to be resolved. After addressing these issues, the pull request should be reviewed again before merging. I am unable to directly approve this pull request, and users should have others review and approve this code before merging.

Comment on lines +1476 to +1533
"default": [
{
"description": "Configure the visual styles for the component",
"displayName": "Styling",
"entityState": [
"declaration"
],
"key": "",
"kind": "mutate",
"schemaVersion": "capability.meshery.io/v1alpha1",
"status": "enabled",
"subType": "",
"type": "style",
"version": "0.7.0"
},
{
"description": "Change the shape of the component",
"displayName": "Change Shape",
"entityState": [
"declaration"
],
"key": "",
"kind": "mutate",
"schemaVersion": "capability.meshery.io/v1alpha1",
"status": "enabled",
"subType": "shape",
"type": "style",
"version": "0.7.0"
},
{
"description": "Drag and Drop a component into a parent component in graph view",
"displayName": "Compound Drag And Drop",
"entityState": [
"declaration"
],
"key": "",
"kind": "interaction",
"schemaVersion": "capability.meshery.io/v1alpha1",
"status": "enabled",
"subType": "compoundDnd",
"type": "graph",
"version": "0.7.0"
},
{
"description": "Add text to nodes body",
"displayName": "Body Text",
"entityState": [
"declaration"
],
"key": "",
"kind": "mutate",
"schemaVersion": "capability.meshery.io/v1alpha1",
"status": "enabled",
"subType": "body-text",
"type": "style",
"version": "0.7.0"
}
]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These default values for capabilities are defined again later in the file. This redundancy can lead to inconsistencies and maintenance issues. Consider removing these default values to keep the schema DRY (Don't Repeat Yourself).

Copy link
Contributor Author

@n2h9 n2h9 May 3, 2025

Choose a reason for hiding this comment

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

hey, gemi, hello 😇
this is auto generated code

@n2h9
Copy link
Contributor Author

n2h9 commented May 3, 2025

Hey @aabidsofi19 👋 hello 😇
We discussed that we could delete default array from capability.json and to do it in this pr, BUT they are referenced by @amitamrutiya here:
https://github.com/amitamrutiya/meshery/blob/master/server/handlers/component_generator_helper.go#L474
so I will NOT touch them in this pr, and in general.

@aabidsofi19
Copy link
Member

Hey @aabidsofi19 👋 😇
We discussed that we could delete default array from capability.json and to do it in this pr, BUT they are referenced by @amitamrutiya here:
https://github.com/amitamrutiya/meshery/blob/master/server/handlers/component_generator_helper.go#L474
so I will NOT touch them in this pr, and in general.

Nice catch , yeah this can be replaced by the default for capabilities from component schema

@aabidsofi19
Copy link
Member

@n2h9 is this good to merge

@n2h9
Copy link
Contributor Author

n2h9 commented May 12, 2025

@n2h9 is this good to merge

hey @aabidsofi19 hello 👋
yes, we could merge it 😇
thank you 🙇‍♀️

@aabidsofi19 aabidsofi19 merged commit 1f1de97 into meshery:master May 12, 2025
2 checks passed
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.

2 participants