@@ -683,7 +683,7 @@ Method GetWebApplicationInfo() [ Internal, Private ]
683683Method CollectResourceInfo () [ Internal , Private ]
684684{
685685 // Get resource info from the %pkg.isc.rest.resourceMap table
686- Set query = " select MediaType, ResourceClass, ResourceName from %pkg_isc_rest.resourceMap where DispatchClass = ?"
686+ Set query = " select MediaType, ResourceClass, ResourceName from %pkg_isc_rest.resourceMap where DispatchClass = ? order by ResourceClass "
687687 Set result = ##class (%SQL.Statement ).%ExecDirect (,query ,..DispatchClass )
688688 If result .%SQLCODE < 0 {
689689 Throw ##class (%Exception.SQL ).CreateFromSQLCODE (result .%SQLCODE , result .%Message )
@@ -736,7 +736,7 @@ Method CollectResourceInfo() [ Internal, Private ]
736736Method CollectActionInfo () [ Internal ]
737737{
738738 // Get action info from the %pkg.isc.rest.actionMap table
739- Set query = " select AcceptsOrNUL, ActionName, ActionTarget, HTTPVerb, ImplementationClass, MediaTypeOrNUL, ResourceClass, ResourceName from %pkg_isc_rest.actionMap where DispatchClass = ?"
739+ Set query = " select AcceptsOrNUL, ActionName, ActionTarget, HTTPVerb, ImplementationClass, MediaTypeOrNUL, ResourceClass, ResourceName from %pkg_isc_rest.actionMap where DispatchClass = ? order by ResourceClass, ActionName, HTTPVerb "
740740 Set result = ##class (%SQL.Statement ).%ExecDirect (,query ,..DispatchClass )
741741 If result .%SQLCODE < 0 {
742742 Throw ##class (%Exception.SQL ).CreateFromSQLCODE (result .%SQLCODE , result .%Message )
@@ -1023,7 +1023,7 @@ Method WriteResourceEndpoints() [ Internal, Private ]
10231023 // Parameter generation
10241024 try {
10251025 // The "nice" way to do this: these are the properties that are reported as being OK to query as reported by DBMappedResource
1026- Set parametersIterator = $ClassMethod (resourceSchema .ClassName , " getProxyColumnList " ).%GetIterator ()
1026+ Set parametersIterator = $ClassMethod (resourceSchema .ClassName , " GetProxyColumnList " ).%GetIterator ()
10271027 } catch (ex ) {
10281028 // TODO: Come up with some way to handle classes that don't use DBMappedResource methods, instead of (incorrectly) listing them as having no parameters.
10291029 // TODO: The following methods theoretically perform known operations:
@@ -1503,7 +1503,7 @@ Method WriteActionEndpoints() [ Internal, Private ]
15031503 For i =1 :1 :..ActionInfo .Count () {
15041504 #dim actionSchema As %pkg.isc.rest.openAPI.actionInfo
15051505 Set actionSchema = ..ActionInfo .GetAt (i )
1506- If ('actionSchema .Supported ) && ((actionSchema .Forbidden && actionSchema .ForbidUnderAllCircumstances ) ||
1506+ If ('actionSchema .Supported ) || ((actionSchema .Forbidden && actionSchema .ForbidUnderAllCircumstances ) ||
15071507 ('..IncludeForbiddenEndpoints && '..ForceAuthorizeAllEndpoints && actionSchema .Forbidden )) {
15081508 Continue
15091509 }
@@ -1576,35 +1576,36 @@ Method WriteActionEndpoints() [ Internal, Private ]
15761576 // Query/Path Parameters
15771577 #Dim parameter As %pkg.isc.rest.openAPI.model.parameter
15781578 Set parameter = " "
1579+ Set found = 0
15791580 For j =1 :1 :methodObj .Parameters .Count () {
15801581 Set existingParameter = methodObj .Parameters .GetAt (j )
15811582 If existingParameter .Name = argument .Name && (existingParameter .In = argument .Source ) {
15821583 Set parameter = methodObj .Parameters .GetAt (j )
1584+ Set found = 1
15831585 Quit
15841586 }
15851587 }
15861588 Set schema = argument .Schema
1587- Set mediatype = ##class (%pkg.isc.rest.openAPI.model.mediaType ).%New ()
1588- Do mediatype .SourceClasses .Insert (argument .SourceClass )
1589- Set mediatype .Schema = schema
15901589 If parameter = " " {
15911590 Set parameter = ##class (%pkg.isc.rest.openAPI.model.parameter ).%New ()
1592- Do parameter .Content . SetAt ( mediatype , argument . MediaType )
1591+ Set parameter .Schema = schema
15931592 } Else {
1594- Set existingSchema = parameter .Content .GetNext (" " )
1595- If $IsObject (existingSchema ) {
1596- Set baseSchema = ##class (%pkg.isc.rest.openAPI.model.schema ).%New ()
1597- Set baseSchema .AutoGenerated = 1
1598- For j =1 :1 :existingSchema .SourceClasses .Count () {
1599- Do baseSchema .SourceClasses .Insert (existingSchema .SourceClasses .GetAt (j ))
1593+ Set baseSchema = parameter .Schema
1594+
1595+ // If we have the same action from multiple sources,
1596+ // don't add duplicate "OneOf" entries with the same reference.
1597+ // (Could do deduplication downstream too.)
1598+ Set foundRef = 0
1599+ If (schema .Ref '= " " ) {
1600+ For j =1 :1 :baseSchema .OneOf .Count () {
1601+ If baseSchema .OneOf .GetAt (j ).Ref = schema .Ref {
1602+ Set foundRef = 1
1603+ }
16001604 }
1601- Do parameter .Content .Clear ()
1602- Set parameter .Schema = baseSchema
1603- Do baseSchema .OneOf .Insert (existingSchema )
1604- } Else {
1605- Set baseSchema = parameter .Schema
16061605 }
1607- Do baseSchema .OneOf .Insert (schema )
1606+ If 'foundRef {
1607+ Do baseSchema .OneOf .Insert (schema )
1608+ }
16081609 For j =1 :1 :schema .SourceClasses .Count () {
16091610 Do baseSchema .SourceClasses .Insert (schema .SourceClasses .GetAt (j ))
16101611 }
@@ -1615,7 +1616,9 @@ Method WriteActionEndpoints() [ Internal, Private ]
16151616 //Set parameter.Description = "TODO: ???"
16161617 // Path parameters are always required
16171618 Set parameter .Required = argument .Required || (argument .Source = " path" )
1618- Do methodObj .Parameters .Insert (parameter )
1619+ If 'found {
1620+ Do methodObj .Parameters .Insert (parameter )
1621+ }
16191622 } ElseIf argument .Source = " body-key" {
16201623 // Body-Key Parameters
16211624 Set requestBody = methodObj .RequestBody
@@ -1983,4 +1986,3 @@ Method WriteSection(text, ByRef ws, ByRef timer) [ Internal, Private ]
19831986}
19841987
19851988}
1986-
0 commit comments