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

Access to OpenAPI 'operation' object in es2022 scripting. #621

Open
cooperaj opened this issue Sep 2, 2024 · 2 comments · Fixed by #668
Open

Access to OpenAPI 'operation' object in es2022 scripting. #621

cooperaj opened this issue Sep 2, 2024 · 2 comments · Fixed by #668
Assignees

Comments

@cooperaj
Copy link

cooperaj commented Sep 2, 2024

I'm trying to do some slightly more complex mocking by using the '@imposter-js/types' library in a built index.js file but am finding that I don't have access to the context.operation object under the Graal interpreter.

Trying to log it out gives me 14:06:34 INFO s./opt/imposter/config/mock-responses - Operation function () { [native code] } - where 'Operation' is a string prefix on the log line. This tells me it's there but it does not behave as I'd expect as trying to use context.operation.operationId does not work.

It looks like the '@imposter-js/types' library does not natively export the context here annoyingly but in this case I think that just results in a lack of autocomplete when editing.

EDIT
I've just discovered that I can instead use the getOperationId() method (after editing my custom types) and this works.

@outofcoffee
Copy link
Owner

Thanks @cooperaj.

We might look at using the js.foreign-object-prototype setting in Graal to see if this can autogenerate the operationId property.

@outofcoffee
Copy link
Owner

outofcoffee commented Dec 12, 2024

Hi @cooperaj, this should be improved in v4.3.0.

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

Successfully merging a pull request may close this issue.

2 participants