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

Is it possible to add custom rules? #240

Open
rao-anant opened this issue Aug 30, 2022 · 5 comments
Open

Is it possible to add custom rules? #240

rao-anant opened this issue Aug 30, 2022 · 5 comments
Labels

Comments

@rao-anant
Copy link

Depending on the usage, we might want to add our rules, or modify existing rules by changing the type etc.
Is it possible to do with openapi-diff?
Thanks!

@jianyexi
Copy link
Contributor

yes, you can create an issue for your new rule, we need to evaluate it

@rao-anant
Copy link
Author

rao-anant commented Aug 31, 2022 via email

@rao-anant
Copy link
Author

rao-anant commented Aug 31, 2022 via email

@jianyexi
Copy link
Contributor

I misunderstood, this repo is open source, so any new feature/idea is welcomed.
Currently the rule is distributed in the C# files, if you want to customize ruleset, to avoid breaking change, we may need to support something like rule configuration in the tool, do you have any proposal for it?

@rao-anant
Copy link
Author

Hello Jianyexi,

Thanks for the suggestion.
Here’s my proposal. Please let me know your feedback.

After processing each change/diff (between the two spec files), you’ll call a plugin developed by me against an interface specified by you.

The interface/plugin takes one input param, which is the context that you are currently printing in the output:
• Id
• Message
• Old struct
• New struct
• Type
• docUrl
• mode

The plugin returns a structure containing:
• A return code
• A new context, possibly. Please read below.

Return code from the plugin:

0
This means my Rules Engine/policy agrees with the determination made by yours. No context is returned. You’ll just print the message as before - that is, message that you already have/prepared.

+1
This means your Rules engine found the change to be backward-Incompatible and mine finds it Compatible. No context is returned by me, and you will not print any message for this change. Basically, you’ll ignore this change as though it didn't exist.

-1
This means your Rules engine found the change to be backward-Compatible and mine finds it Incompatible. A new context is returned in this case and you’ll print this new context (instead of the one you have/prepared).

The context I return will have new values for the following fields and the rest of the fields will be copied from the context given in the input:

• Id (You can reserve codes >= 5000 for plug-in developers. As an example, I might return 5001)
• Message – My customized message
• Type
• docUrl -> This could potentially point to my URL

Please let me know your thoughts.
Thanks very much!
Anant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants