oasis-tcs / odata-openapi

OASIS OData TC: Tools for producing API descriptions for OData services that adhere to the OpenAPI Specification
https://oasis-tcs.github.io/odata-openapi/
Other
196 stars 81 forks source link

OData V2 EDM.Binary Wrong Conversion #304

Closed nilskasseckert closed 3 months ago

nilskasseckert commented 3 months ago

Hello, the generator converts the following OData-XML specification:

    <Property Name="Content"
                          Type="Edm.Binary"
                          Nullable="false"
                          sap:unicode="false"
                          sap:label="Dateiinhalt"
                          sap:heading="Dateiinhalt (Binärdaten)"
                          sap:quickinfo="Dateiinhalt als binärer Datenstrom"
                          sap:sortable="false"
                          sap:filterable="false"/>

into the following OpenAPI:

"Content": {
            "type": "string",
            "format": "base64url"
          },

This is completely correct for the V4 world and corresponds to the OASIS specification.

For V2, however, it should be base64 and not base64url. SAP says:

OData V2 uses a different alphabet for the base-64 encoding forEdm.binary. OData V2 uses '+' and '/' but OData V4 uses instead '-' and '_'.

If I'm not wrong an if is missing here to handle the different cases: https://github.com/oasis-tcs/odata-openapi/blob/d00aabe484050b51d269c3e524f2915adf852c3d/lib/csdl2openapi.js#L2480C5-L2486C15

Regards, Nils

ralfhandl commented 3 months ago

Hi @nilskasseckert,

Thanks for finding this!

Fix is published with odata-openapi@0.26.1

nilskasseckert commented 3 months ago

Hi @ralfhandl, thanks for the fast fix! Works now!

Regards, Nils