Skip to content

Reference resolve issue for 3GPP Rel.16 definitions #638

@ShouheiNishi

Description

@ShouheiNishi

We are trying to generate code with the oapi-codegen from the 3GPP Rel.16 openapi definition .yaml file, but the reference resolution fails in the kin-openapi loader and the file cannot be loaded.

We use these files. All files are got from 3GPP webpage.
But encode of TS29544_Nspaf_SecuredPacket.yaml is fixed by hand.
The file from which the import is started is TS29571_CommonData.yaml.

TS28623_GenericNrm.yaml
TS28623_comDefs.yaml
TS29122_AsSessionWithQoS.yaml
TS29122_ChargeableParty.yaml
TS29122_CommonData.yaml
TS29122_CpProvisioning.yaml
TS29122_DeviceTriggering.yaml
TS29122_ECRControl.yaml
TS29122_GMDviaMBMSbyMB2.yaml
TS29122_GMDviaMBMSbyxMB.yaml
TS29122_MonitoringEvent.yaml
TS29122_MsisdnLessMoSms.yaml
TS29122_NIDD.yaml
TS29122_NpConfiguration.yaml
TS29122_PfdManagement.yaml
TS29122_RacsParameterProvisioning.yaml
TS29122_ReportingNetworkStatus.yaml
TS29122_ResourceManagementOfBdt.yaml
TS29502_Nsmf_PDUSession.yaml
TS29503_Nudm_EE.yaml
TS29503_Nudm_MT.yaml
TS29503_Nudm_NIDDAU.yaml
TS29503_Nudm_PP.yaml
TS29503_Nudm_SDM.yaml
TS29503_Nudm_UEAU.yaml
TS29503_Nudm_UECM.yaml
TS29505_Subscription_Data.yaml
TS29507_Npcf_AMPolicyControl.yaml
TS29508_Nsmf_EventExposure.yaml
TS29509_Nausf_SoRProtection.yaml
TS29509_Nausf_UEAuthentication.yaml
TS29509_Nausf_UPUProtection.yaml
TS29510_Nnrf_AccessToken.yaml
TS29510_Nnrf_Bootstrapping.yaml
TS29510_Nnrf_NFDiscovery.yaml
TS29510_Nnrf_NFManagement.yaml
TS29512_Npcf_SMPolicyControl.yaml
TS29514_Npcf_PolicyAuthorization.yaml
TS29517_Naf_EventExposure.yaml
TS29518_Namf_Communication.yaml
TS29518_Namf_EventExposure.yaml
TS29518_Namf_Location.yaml
TS29518_Namf_MT.yaml
TS29519_Application_Data.yaml
TS29519_Exposure_Data.yaml
TS29519_Policy_Data.yaml
TS29520_Nnwdaf_AnalyticsInfo.yaml
TS29520_Nnwdaf_EventsSubscription.yaml
TS29522_5GLANParameterProvision.yaml
TS29522_ACSParameterProvision.yaml
TS29522_AnalyticsExposure.yaml
TS29522_ApplyingBdtPolicy.yaml
TS29522_IPTVConfiguration.yaml
TS29522_LpiParameterProvision.yaml
TS29522_MoLcsNotify.yaml
TS29522_NIDDConfigurationTrigger.yaml
TS29522_ServiceParameter.yaml
TS29522_TrafficInfluence.yaml
TS29523_Npcf_EventExposure.yaml
TS29531_Nnssf_NSSAIAvailability.yaml
TS29531_Nnssf_NSSelection.yaml
TS29544_Nspaf_SecuredPacket.yaml
TS29554_Npcf_BDTPolicyControl.yaml
TS29571_CommonData.yaml
TS29572_Nlmf_Broadcast.yaml
TS29572_Nlmf_Location.yaml
TS32291_Nchf_ConvergedCharging.yaml
TS32291_Nchf_OfflineOnlyCharging.yaml

The error message is here.

error loading swagger spec in lib/openapi/Rel16/yaml/TS29571_CommonData.yaml
: error resolving reference "TS29510_Nnrf_AccessToken.yaml#/components/schemas/AccessTokenReq": error resolving reference "TS29510_Nnrf_NFManagement.yaml#/components/schemas/NFType": error resolving reference "TS29518_Namf_Communication.yaml#/components/schemas/N2InformationClass": error resolving reference "TS29518_Namf_EventExposure.yaml#/components/schemas/AmfEventSubscription": error resolving reference "TS29503_Nudm_EE.yaml#/components/schemas/ReferenceId": error resolving reference "TS29503_Nudm_SDM.yaml#/components/schemas/ContextInfo": error resolving reference "TS29503_Nudm_PP.yaml#/components/schemas/PlmnEcInfo": error resolving reference "TS29572_Nlmf_Location.yaml#/components/schemas/CivicAddress": failed to resolve "ProblemDetails" in fragment in URI: "#/components/schemas/ProblemDetails": map key "ProblemDetails" not found

We analyze loader code. We found some issues.
The arguments 'doc’ and 'path’ of the function 'resolveComponent’ in 'loader.go’ is sometimes incorrect. In such case, resolving reference is failed.
In the function 'resolveSchemaRef’, the aregumnt 'doc’ for recursive call of 'resolveSchemaRef’ must be use a value that points to the referenced document.
In these code

			var resolved SchemaRef
			componentPath, err := loader.resolveComponent(doc, ref, documentPath, &resolved)
			if err != nil {
				return err
			}
			if err := loader.resolveSchemaRef(doc, &resolved, componentPath, visited); err != nil {
				return err
			}
			component.Value = resolved.Value
			return nil
			foundPath := loader.getResolvedRefPath(ref, &resolved, documentPath, componentPath)
			documentPath = loader.documentPathForRecursiveRef(documentPath, foundPath)

We think that there should be no processing after updating the value of 'component.value' and should return to the calling function immediately.

The attached diff seems to resolve the issue, but I am not sure about the validity.
In addition, we could not generate the smallest pattern to reproduction this issue.

test-fix.diff.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions