2022-innovator-challenge / cloud-sdk-js

Use the SAP Cloud SDK for JavaScript / TypeScript to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
0 stars 0 forks source link

Error when compiling generated code #3

Open florian-richter opened 2 years ago

florian-richter commented 2 years ago

Describe the bug Hi, I am trying to generate a client for a service that uses inheritance (has entities with a BaseType). The client generates typescript files but they won't compile as the inheriting entities don't have key properties.

To Reproduce Use this MWE.

service-specs/service-mapping.json:

{
  "test": {
    "directoryName": "test",
    "servicePath": "/test",
    "npmPackageName": "test"
  }
}

service-specs/test.edmx:

<?xml version='1.0' encoding='UTF-8'?>
<edmx:Edmx 
  xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
  <edmx:DataServices m:DataServiceVersion="1.0" 
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <Schema Namespace="ns" 
      xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
      <EntityType Name="MyBaseType">
        <Key>
          <PropertyRef Name="id"/>
        </Key>
        <Property Name="id" Type="Edm.String" Nullable="false"/>
      </EntityType>
      <EntityType Name="MyType" BaseType="ns.MyBaseType">
        <Property Name="name" Type="Edm.String" Nullable="true"/>
      </EntityType>
      <EntityContainer Name="DefaultContainer" m:IsDefaultEntityContainer="true">
        <EntitySet Name="MyType" EntityType="ns.MyType"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "generate-client": "generate-odata-client -i service-specs -o generated --forceOverwrite --clearOutputDir"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@sap-cloud-sdk/connectivity": "^2.6.0",
    "@sap-cloud-sdk/odata-common": "^2.6.0",
    "@sap-cloud-sdk/odata-v2": "^2.6.0",
    "@sap-cloud-sdk/util": "^2.6.0"
  },
  "devDependencies": {
    "@sap-cloud-sdk/generator": "^2.6.0"
  }
}

Steps to reproduce the behavior:

  1. Create files above
  2. Run command npm run generate-client
  3. Notice that service generation fails

Expected behavior The cloud SDK should generate valid typescript code. In this case it should respect entity inheritance and merge all properties and especially the key.

Used Versions:

Impact / Priority

This is for an internal project only. There is no deadline. I will try to adjust the metadata so that there is no inheritance.

Additional context Instead of using the MWE above, you can also use SAP's IntegrationContent service at https://api.sap.com/api/IntegrationContent/overview. This is the service that I wasn't able to use because of the bug.

florian-richter commented 2 years ago

!similar

bot-sdk-js commented 2 years ago

These are the most similar issues to "Error when compiling generated code":

🤖 💬 I hope this was helpful. BEEP BOOP.