SAP / open-ux-tools

Enable community collaboration to jointly promote and facilitate best in class tooling capabilities
Apache License 2.0
83 stars 39 forks source link

FEATURE - retrieve OData metadata for `ValueListReferences` #389

Open Klaus-Keller opened 2 years ago

Klaus-Keller commented 2 years ago

As a consumer of the @sap-ux/axios-extension (former odata-client), I want to be able to download metadata of referenced value help services, so that I can create mock data for them.

Description

Starting with SAP Fiori elements for OData V4, value helps of applications are modeled as separate OData service endpoints. In order to write automated tests, there might be the need for mocking value help data. To be able to create mock data for value helps, we need to know the data structure behind them. This data structure can be retrieved from metadata of each value help service endpoint.

Technical Design

The module @sap-ux/axios-extension (former odata-client) allows structured access to OData services. It provides functionality to retrieve the metadata. For an OData V4 service, this metadata might contain one or multiple annotations SAP__common.ValueListReferences that points to the URL of a value help service. Instead of parsing the metadata for value help references by each consumer, module @sap-ux/axios-extension could provide this functionality allowing convenient access to the metadata and metadata of all included value help references.

Acceptance Criteria

Given I have a OData V4 service including value help references when I execute the function to retrieve value help metadata then I'll be able to store metadata of all referenced value help.

Notes

Example Metadata for V4 List Report Object Page service contains:

...
<Annotation Term="SAP__common.ValueListReferences">
  <Collection>
    <String>relative/path/to/value/list/$metadata</String>
  </Collection>
</Annotation>
...

This means, the metadata for value help values can be found at: relative/path/to/value/list/$metadata

Tasks

tobiasqueck commented 2 years ago

@Klaus-Keller I am not sure this should go into the @sap-ux/axios-extension (#75) since it would require that it parses the metadata. So far, the module only simplifies getting the metadata but does not do anything with it. Your scenario could be easily implemented outside of the module with.

import { ODataServiceProvider } from '@sap-ux/axios-extension';

const provider = ODataServiceProvider.create({
    baseURL: 'https://sap.example',
    params: { 'sap-client': client }
});
const service = provider.service('/ns/my_service');
const metadata = await service.metadata();

const valueListRefs = {};
yourParser(metadata).forEach((ref) => {
   valueListRefs[ref] = await provider.service(ref).metdata();
});
tobiasqueck commented 1 year ago

@Klaus-Keller I am assuming that this is not needed anymore since it has not been touched in 12+ months. If this is wrong, then please reopen.

Klaus-Keller commented 1 year ago

Reopening this as it came up as requirement. Details will follow.