Great article! Thank you @Pablo Frigolett !

Also, if you develop in Docker there is an issue with server name, and my version of the same GetSpec method is:

ClassMethod GetSpec() As %DynamicObject

{

Set spec = {}.%FromJSON(##class(%Dictionary.CompiledXData).%OpenId("dc.Sample.v2rest.spec||OpenAPI").Data)

Set url = $Select(%request.Secure:"https",1:"http") _ "://"_$Get(%request.CgiEnvs("SERVER_NAME")) _ ":" _ $Get(%request.CgiEnvs("SERVER_PORT")) _ %request.Application

Set spec.servers = [{"url" : (url)}]

Quit spec

}

Thanks to @Lorenzo Scalese !

Hi @Anna Golitsyna ! I appreciate you watched the video. Indeed it (AI Copilot) is not that bad sometimes especially in simple cases and sometimes can even surprise like "reading thoughts" what to put next so VSCode+Copilot could be more effective in coding ObjectScript vs just Studio and occasional copy-paste from ChatGPT.

But I agree with @Dmitry Maslennikov that the very fact that AI can "talk" ObjectScript/Mumps is mostly because of Open Exchange initiative and its impact on Github.com, where ObjectScript is listed as a recognizable language (thanks again to @Dmitry Maslennikov to his impact to it about 10 years ago).
 

Yes. But you cannot return String in this method - either dynamic object, or Stream object.

BTW, I’d even expect this functionality over %JSON.Adapter, as there is an option to import (construct) persistent from dynamic in it:

Set person=##class(dc.Sample.Person).%New()

do person.%JSONImport(dynamicPerson)

But person.%JSONExport() does JSON string into device. Would be wonderful to have:

D person.%JSONExport(.dynobj)

Wow, @Robert Cemper ! Thank you as usual! 

But 3 lines. Could it be a one command by any chance? :)

I compete with the following:

/// Get JSON for a person with a given id

ClassMethod personsidGET(messageRequest As dc.Sample.v3rest.requests.personsidGET) As %Status

{

 Set person = ##class(dc.Sample.Person).%OpenId(messageRequest.pathid)

 set stream=##class(%Stream.TmpCharacter).%New() 

 d person.%JSONExportToStream(.stream)

 return stream

}

This works, but with an unnecessary "to stream, out of stream" exercise IMHO.

The example is in your article:

Class petstoreserver.impl Extends %REST.Impl [ ProcedureBlock ] { Parameter ExposeServerExceptions = 1; 
/// Service implemntation for post /pet 
ClassMethod addPet(messageRequest As petstoreserver.requests.addPet) As %Status
{ ; Implement your service here. 
  ; Return {} 
 $$$ThrowStatus($$$ERROR($$$NotImplemented)) 
    
} ... }

The declaration returns %Status.

The generated stub suggests return {} meaning the method should return json (which is true)

and below it throws status.

I think nothing can be fixed here :) Do we have any datatype to provide meaning that we expect the method to return JSON? %JSON? ))

But this discrepancy is quite confusing when you look at it for the first time.