Question
Marcos Costa · Nov 8, 2021

Wrong method signature when building REST implementation class using spec

When using the REST API classes for building services on a spec-first approach, the implementation class methods are usually built this format:

ClassMethod <method-name>(body As %DynamicObject) As %Stream.Object

But sometimes it keeps building the endpoint implementation method like this:

ClassMethod <method-name>(body As %Stream.Object) As %DynamicObject

It has been a problem because the rest of my implementation rely on the fact that the "body" object is a DynamicObject.

The REST spec is exactly the same for all endpoints, but this last it built keeps presenting this problem.

Someone has experienced the same issue?

Product version: IRIS 2021.1
0
0 259
Discussion (3)2
Log in or sign up to continue

Marcos,

I was going through some unanswered questions and came across yours. If you could share your spec to DM it to me I can take a look.

However, understand that the %Stream.Object probably contains the JSON payload that you need.  As such you can get your dynamic object with the following command:

set dyObject = {}.%FromJSON(body)

hope that helps.

Rich, thanks for your reply.

I found out that the method signature the REST lib builds depends on the MIME type defined on the "produces" and "consumes" swagger properties.

After adjusting the spec class with the correct values for those properties the methods signatures were built the same format of the others.

Great that you found that and can adjust those properties to your liking.

Best of luck in your development work.