-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: expose resolved document #433
Conversation
src/spectral.ts
Outdated
@@ -42,7 +43,18 @@ export class Spectral { | |||
this._resolver = opts && opts.resolver ? opts.resolver : new Resolver(); | |||
} | |||
|
|||
public async run(target: IParsedResult | object | string, opts: IRunOpts = {}): Promise<IRuleResult[]> { | |||
public async run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whaaaaaat is this. Does TypeScript have overloading?
I have a funny feeling in my stomach, and I don't think it's just because of the North Sea. Did you consider alternate methods which can be called to return the resolved doc and results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, all of them have some pros and cons.
For me, the most reasonable one would be to have getResolved
method, but the gotcha here is that one would need to call run
beforehand.
This is going to have conflicts with #430, I think we should focus on that one then come back to this? |
@philsturgeon What do you all think about the potential solutions? That run with those overloads seems weird.
This would let us add more data if we'd ever need to. |
This is a tricky one for sure. How about a 2nd I prefer this to overloading and "argument changes response type" style code. |
|
8348925
to
6e1dbfd
Compare
* feat: expose resolved document * refactor: runWithResolved
* feat: expose resolved document * refactor: runWithResolved
Closes #398
Checklist
Does this PR introduce a breaking change?
We haven't settled on any final implementation just yet, therefore the following PR is more about exposing a place to discuss the final solution.
I know we could do it in the related GitHub issue, but having everything shown in the code should make it easier to reason about.
@nulltoken looking forward to your input! :)
In general, there are a couple of other ways to accomplish that. I'm afraid that all of them have some drawbacks. I'll try to list 3 other solutions I can think of.
Note, all the concepts would result in non-breaking functionality.
resolved
public property that whose value would assigned whenrun
method is executedonResolve
callback somewhere inrun
function, most likely right after resolving is completedAs you can see, all of them are kind of weird.
Ideally,
run
method would always return some metadata next to validation results, but this would be breaking.