You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many of our emitters have options that are a path to a directory or a file. They are very incositent on their handleing and by default end-up being resolved relative to the current working directory. For example the examples-directory in the autorest emitter.
It would be nice to provide a way so an emitter can say this option is a path and that way the compiler could automatically interpolate it with the {project-root} or {cwd} if done explicitly and complain if the path is a relative path.
A potential approach would be to have the emitter options be defined in TypeSpec itself:
import "@typespec/compiler/emitter-options";
model EmitterOptions {
`examples-dir`: TypeSpec.EmitterOptions.path
}
but maybe in the meantime we can just add that as a format or x-path: true extension in the jsonschema
The text was updated successfully, but these errors were encountered:
If we had way to define option in typespec, could imagine the following:
import "@typespec/compiler/emitter-options";
model EmitterOptions {
`examples-dir`: TypeSpec.EmitterOptions.absolutePath,
`sub-folder`: TypeSpec.EmitterOptions.relativePath
}
Actually defining the options in typespec is not the core part of this proposal but this is what it would look like. It would anyway need to be compiled to some easy to parse format(like jsonschema) so compiler doesn't need to compile typespec to compile more typespec
In jsonschema
type: stringformat: absolute-path
type: stringformat: relative-path
Behavior
The expected behavior is when resolving the options the compiler would automatically validate that a path is actually absolute or complain if not. This would make sure user explicilty use {project-root} or {cwd}
Relative path would still be useful when interpolating things that can be undefined like path/{version}/foo.json and if version is undefeined it would produce path/foo.json instead of path//foo.json
Other things would be path complaining about backslash which cause so many issues
Many of our emitters have options that are a path to a directory or a file. They are very incositent on their handleing and by default end-up being resolved relative to the current working directory. For example the
examples-directory
in the autorest emitter.It would be nice to provide a way so an emitter can say this option is a path and that way the compiler could automatically interpolate it with the
{project-root}
or{cwd}
if done explicitly and complain if the path is a relative path.A potential approach would be to have the emitter options be defined in TypeSpec itself:
but maybe in the meantime we can just add that as a
format
orx-path: true
extension in the jsonschemaThe text was updated successfully, but these errors were encountered: