You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:47:13 UTC
[GitHub] [camel-k-runtime] nicolaferraro opened a new issue #358: Generate schema for YAML DSL
nicolaferraro opened a new issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358
That will be useful to help tooling
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652409954
@apupier I've generated one that does not have warnings from the json schema validator https://gist.github.com/lburgazzoli/8235a92c474ba049901f747abcf064f5 which also includes the fix for the array type
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652428068
> what is a `step_from` ?
> yep, naming has fixed now but cant get vscode to work for me
it was problem of naming. it should be `from`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652407040
i think this part is incorrect:
```
"steps" : {
"type" : "array",
"items" : {
"type" : "string"
},
"java_type" : "java.util.Collection"
}
```
it explains why after the steps, you can put only a string.
but searching for the correct notation
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lhein commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lhein commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652427419
what is a `step_from` ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli closed issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli closed issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-653090046
last version from https://gist.githubusercontent.com/lburgazzoli/5b860fdad50d372a27fc51306f1ae378/raw/addea32147720a41ff58aa82e1ec845dae6ab77c/camel-yaml-dsl.json seems to be valid.
Unfortunately, it seems it is hitting a bug in VS Code Yaml https://github.com/redhat-developer/vscode-yaml/issues/310
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652432435
> There is an error message `Matches multiple schemas when only one must validate.` but it smells a limitation on yaml Language server. it seems there is a workaround to shut ignore the error in the yaml language server especially for that for Kubernetes schema https://github.com/redhat-developer/yaml-language-server/blob/8f8a4c52363d2c8c003e08b12cb7db97550afbca/src/languageservice/services/yamlValidation.ts#L91
in fact, it seems that it is coming from https://github.com/microsoft/vscode-json-languageservice/blame/fad098244642100e5054dedefed9da905b24aedc/src/parser/jsonParser.ts#L458 and Yaml Language Server has put a workaround flag to ignore this error.
If i understand well, this message is provided when several different elements are matching the same tag.
I found that several json schema has been modified to avoid that it occurs but wasn't able to find a pattern on how they fixed it.
For Kubernetes, it seems that they just put the silent mode at Yaml language Server level.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652388145
I've been progressing on this but I'm on a point I don0t know what's wrong with my schema so I need a little bit of help understanding why I'm unable to get completion working for some of the fields.
Here a stripped-down version of the generated schema:
```json
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"type" : "array",
"items" : {
"definitions" : {
"steps" : {
"from" : {
"type" : "object",
"properties" : {
"parameters" : {
"type" : "object",
"java_type" : "java.util.Map"
},
"steps" : {
"type" : "array",
"items" : {
"type" : "string"
},
"java_type" : "java.util.Collection"
},
"uri" : {
"type" : "string"
}
},
"steps" : {
"type" : "array",
"items" : {
"$ref" : "#/items/definitions/step"
}
}
},
"to" : {
"oneOf" : [ {
"type" : "string",
"java_type" : "java.lang.String"
}, {
"type" : "object",
"properties" : {
"pattern" : {
"type" : "string",
"enum" : [ "InOnly", "InOut", "InOptionalOut" ]
},
"uri" : {
"type" : "string"
},
"inherit-error-handler" : {
"type" : "boolean",
"alias" : "inheritErrorHandler"
}
},
"required" : [ "uri" ]
} ]
},
"log" : {
"definition-class" : "org.apache.camel.model.LogDefinition",
"oneOf" : [ {
"type" : "string",
"java_type" : "java.lang.String"
}, {
"type" : "object",
"properties" : {
"log-name" : {
"type" : "string",
"alias" : "logName"
},
"logger-ref" : {
"type" : "string",
"alias" : "loggerRef"
},
"logging-level" : {
"type" : "string",
"alias" : "loggingLevel",
"enum" : [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ]
},
"marker" : {
"type" : "string"
},
"message" : {
"type" : "string"
},
"inherit-error-handler" : {
"type" : "boolean",
"alias" : "inheritErrorHandler"
}
}
} ]
}
},
"step" : {
"type" : "object",
"oneOf" : [ {
"properties" : {
"process" : {
"$ref" : "#/items/definitions/steps/from"
}
}
}, {
"properties" : {
"resequence" : {
"$ref" : "#/items/definitions/steps/to"
}
}
}, {
"properties" : {
"rest" : {
"$ref" : "#/items/definitions/steps/log"
}
}
} ]
}
},
"oneOf" : [ {
"properties" : {
"from" : {
"$ref" : "#/items/definitions/steps/from"
}
}
} ]
}
}
```
When configuring VSCode to use it for auto completion of camel-k routes written in YAML, I can get suggestions for all the fields of the `from` definition, however, I get no completion for the `steps` fields and the only suggestion is literally `null`

@lhein @apupier I'd really appreciate if you can help me finding out the reason why the auto-completion do not work as the schema appears to be correct but there's certainly something I'm missing.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-645240701
The Yaml tooling is using json files for yaml schema. see https://github.com/redhat-developer/vscode-yaml#associating-a-schema-to-a-glob-pattern-via-yamlschemas
by publishing it on https://www.schemastore.org/json/ it will allow several IDEs to leverage it automatically https://github.com/apache/camel-k/issues/1538
To be useful in IDEs, it must be the schema of the "design definition". it is important in case the runtime one is different.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652390609
This online schema validator is saying that there is a problem with the `steps` elements:
https://json-schema-validator.herokuapp.com/syntax.jsp
```
[ {
"level" : "warning",
"schema" : {
"loadingURI" : "#",
"pointer" : "/items/definitions/steps"
},
"domain" : "syntax",
"message" : "the following keywords are unknown and will be ignored: [from, log, to]",
"ignored" : [ "from", "log", "to" ]
} ]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652836299
tested by replacing `oneOf` with `anyOf` on the version provided in this comment https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652409954 and it works like a charm
It remains to have a version with the fix for `step_xxx` too to ensure that it is working fine.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli edited a comment on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli edited a comment on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652409954
@apupier I've generated one that does not have warnings from the json schema validator https://gist.github.com/lburgazzoli/8235a92c474ba049901f747abcf064f5 which also includes the fix for the array type, but still can't get completion
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652425802
yep, naming has fixed now but cant get vscode to work for me
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] davsclaus commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-643974809
Hmm what format should the schema be in - also yaml ;) Or does the tooling use those model .json files we have today, or the XML XSD file.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652841185
@apupier here https://gist.github.com/lburgazzoli/7954fa691cb33a3502aa14df0ec7235b an updated gist, it still lack support for complex EIP such as when/choice but I'm working on it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652832852
> > There is an error message `Matches multiple schemas when only one must validate.` but it smells a limitation on yaml Language server. it seems there is a workaround to shut ignore the error in the yaml language server especially for that for Kubernetes schema https://github.com/redhat-developer/yaml-language-server/blob/8f8a4c52363d2c8c003e08b12cb7db97550afbca/src/languageservice/services/yamlValidation.ts#L91
>
> in fact, it seems that it is coming from https://github.com/microsoft/vscode-json-languageservice/blame/fad098244642100e5054dedefed9da905b24aedc/src/parser/jsonParser.ts#L458 and Yaml Language Server has put a workaround flag to ignore this error.
>
> If i understand well, this message is provided when several different elements are matching the same tag.
> I found that several json schema has been modified to avoid that it occurs but wasn't able to find a pattern on how they fixed it.
> For Kubernetes, it seems that they just put the silent mode at Yaml language Server level.
as suggested here https://github.com/microsoft/vscode-json-languageservice/issues/60#issuecomment-652753506 using `anyOf` instead of `oneOf` should avoid the warning.
From what I understand of the difference between the two is only at validation where the `oneOf` is that we want a single possible schema.
http://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.2
<pre><code>
9.2.1.2. anyOf
This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.
An instance validates successfully against this keyword if it validates successfully against <b>at least one schema</b> defined by this keyword's value. Note that when annotations are being collected, all subschemas MUST be examined so that annotations are collected from each subschema that validates successfully.
9.2.1.3. oneOf
This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.
An instance validates successfully against this keyword if it validates successfully against <b>exactly one schema</b> defined by this keyword's value.
</pre>
so i think that we need to use `anyOf` instead of `oneOf` in our case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] apupier commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
apupier commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652400908
pinged a Yaml Language Server developer https://coreos.slack.com/archives/CK14U2L4V/p1593607875269800
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-k-runtime] lburgazzoli commented on issue #358: Generate schema for YAML DSL
Posted by GitBox <gi...@apache.org>.
lburgazzoli commented on issue #358:
URL: https://github.com/apache/camel-k-runtime/issues/358#issuecomment-652395878
That one complains but other don't and AFAIK, the json pointer are correct (in fact VSCode / IDEA follow the paths without issues).
For what I know, it does not like the nesting, like `/items/definitions/steps` and you can put them one level up by removing `steps` which makes the validator happy but don't fix the auto-completion, or at least I was unable to make it working.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org