-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Define options for projects by JSON Schemas #249
Comments
This is something I was thinking about as well. As CLI depends on other tools, when they introduce some breaking changes it will automatically trigger a new release in CLI and it could also break. I liked the idea, just trying to understand will the spec for diff look something like this. properties:
format:
enum:
- json
- yaml
type:
oneOf:
enum:
- breaking
- non-breaking
- unclassified
- all Some questions |
Yes it should look like your example but without
Every tool should have JSON Schema (spec) and corresponding function in the codebase due to simple fact: if someone will add new feature or introduce breaking change should also update that spec and function in this same PR, so separate library isn't an option. EDIT: @Souvikns Also for diff we should define two AsyncAPI spec like: properties:
...
asyncapis:
items: ...
minItems: 2
maxItems: 2 |
Just so that I understand this clearly, |
Yep, but that function should handle some custom logic on passed data (based on JSON Schema). I gave example for modelina where we need change language type to the corresponding language generator (in JSON Schema you cannot pass references to the object), so we also cover such a case. |
I was playing around with the idea and was thinking if we can create cli plugins in the source code itself. So like in every tool we can have a
In place of options, we export CLI parameters like
|
@Souvikns Thanks for your response!
I like that idea, but remember that not only CLI should be supported, but also Studio and ServerAPI, that's why I chose JSON Scheme. We can think about the function that performs the logic on the library side, but I would rather go into the JSON Scheme and turn the JSON Scheme into flags on the side of the CLI itself. In the future we can change the framework for CLI again and it will be a big problem and JSON Scheme is more generic :)
It can be propose as idea, however GSOC will end at the September and I don't think if we should wait for it that long. Solving the given problem itself is quite important for me, because I would not like to duplicate code in integrations. Waiting 6-7 months for this will be quite a problem, because we will integrate a significant part of our ecosystem and then start rewriting... Of course if someone would like to have this at GSOC then ok, but still, this is not a feature that can wait a year (in my opinion). |
Thanks for the clarification @magicmatatjahu 😄
Yeah, make sense.
I know CLI very well so was just thinking in its terms. I will read up on studio and ServerAPI and try to think how we can have something that would be useful to these and also some new tools that might be written in the future. |
I have an idea about how we can create one single JSON definition and use it in all other tools be it in For example - This is the integration function that // bundler integration function
const bundle = require('@asyncapi/bundler');
async function bundler(inputs,options, output) {
const files = inputs.files;
const base = options.base;
const format = output.format;
const document = await bundle(files, {
base: base
})
if(format === 'json') {
return document.json()
}
if(format === 'yaml') {
return document.yml()
}
if(format == 'string') {
return document.string();
}
return format.json();
}
module.exports = bundler; And this is the JSON spec that the type: object
properties:
name:
type: 'string'
inputs:
type: object
properties:
files:
type: array
items:
type: string
options:
type: object
properties:
base:
type: string
output:
type: object
properties:
format:
enum:
- json
- yaml
required: ['name', 'inputs', 'files'] @magicmatatjahu could we use this format to integrate |
@Souvikns It's one of the possible solution but I don't like the properties:
input:
type: object
properties:
files:
type: array
items:
type: [string, object]
options:
type: object
properties:
base:
type: string
format:
enum:
- json
- yaml The format itself is in the bundler options -> https://github.com/asyncapi/bundler/blob/master/lib/index.js#L26 |
In my opinion // bundler integration function
const bundle = require('@asyncapi/bundler');
async function bundler(inputs,options, output) {
const files = inputs.files;
const base = options.base;
const format = output.format;
const document = await bundle(files, {
base: base
})
if(format === 'json') {
return document.json()
}
if(format === 'yaml') {
return document.yml()
}
if(format == 'string') {
return document.string();
}
return format.json();
}
module.exports = bundler; I was thinking like this because the main reason we are doing this is so that I as a bundler maintainer does not have to care how bundler is implemented because this is the function that is going to run in all other tools, and by the specification I get to control what input and output my function shall get. |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
@Souvikns Sorry for such a delay 😅 To your last comment about |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Today we have more and more projects to maintain and develop in our organization. We have decided that one of our main goals of this year will be to strongly develop the Studio as well as CLI.
One problem to meet this goal is the integration of other tools into those listed. E.g.
diff
integration into CLI,modelina
integration into Studio etc. Currently every integration is the same - we do PR to CLI/Studio/Server-API, then review and we have a new integration. However, I see several (but mainly two) problems here:diff
we recently added the possibility to have output asyaml
) we have to add this change also in Studio/CLI/Server-API.I wonder if we can standardize the integration of tools to others using JSON Schema. The whole idea would be to create a JSON Scheme for each tool (in the source code of project) that would describe the options for that project. E.g. in
modelina
it would be the language, info how to transform fields (camelCase
,snakeCase
etc) and a corresponding function that would transform the options described by this JSON Schema to the corresponding options in the project. This is easier to describe with an example. Consider for examplemodelina
:JSON Schema:
Function:
Above is an example of how it could look like. Why do we need JSON Schema and this function?
modelina
). The task of this function will be just to convert data entered via CLI parameters/forms in Studio/JSON in ServerAPI to proper options representation in tool.I can see several benefits of such a solution:
However, some problems must be noted:
modelina
, we have new version 2.0.0 and then should CLI also have breaking change?What do you think about that idea? Of course, this is just an "suggestion" to help with integration, that we should discuss.
The text was updated successfully, but these errors were encountered: