Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
955 stars 197 forks source link

[Enhancement]: The rest endpoint is in the background odata. But it doesn't present an OData MetadataEndpoint #1566

Open paule96 opened 1 year ago

paule96 commented 1 year ago

What happened?

The /rest/... of the genereated API contains at the end technically an ODATA endpoint. But the problem is for many API tools is, that the generated part doesn't make the $metadata endpoint accessible. This endpoint is for example used in PowerBi to be connected to an OData API and get the schema and all valid endpoints from it.

So my expactation would be that I could call:

rest/$metadata and get the XML schema of the OData feed back.

Currently I get:

{"error":{"code":"EntityNotFound","message":"Invalid Entity path: $metadata.","status":404}}

Version

Azure Static Web Apps CLI (1.1.3)

What database are you using?

Azure SQL

What hosting model are you using?

Static Web Apps (SWA)

Which API approach are you accessing DAB through?

REST

Relevant log output

No response

Code of Conduct

Aniruddh25 commented 1 year ago

Hi @paule96,

Thank you for raising this. The REST endpoint support we enabled so far tries to adhere to the Microsoft REST API guidelines here. And we indeed added OData style $filter clauses. However, we haven't completely added the OData support. This would be a new feature request and not considered as a bug.

In the meantime, if you are interested in getting the metadata of the exposed REST endpoints, you could retrieve the OpenAPI document which the latest version of Data API builder - 0.7.6 - generates. This OpenAPI description document (also referred to as a schema file) is generated using the developer provided runtime config file and the database object metadata for each REST enabled entity defined in the runtime config file. The schema file is generated using functionality provided by the OpenAPI.NET SDK. Currently, the schema file is generated in adherence to OpenAPI Specification v3.0.1 formatted as JSON.

The OpenAPI description document can be fetched from Data API builder from the path:

GET /{rest-path}/openapi

In Development mode, Data API builder enables viewing the generated OpenAPI description document from a dedicated endpoint:

GET /swagger

paule96 commented 1 year ago

Uff yes I realize now that many things from OData are missing, like expand... So maybe we should relable the issue to an epic to bring most of the odata funcitons to the odata builder.

For example what I was trying was the $expand option in odata. (/rest) It's not working too. In the graphql endpoint there are no problems for that. (if you define the relation between your entities)

paule96 commented 1 year ago

Just to have the correct informations, if I want to implement the metadata document the following things are a todo:

This work would enable also the implementation of $expand inside the RequestParser, because the relations are required for the metadata endpoint, and can be accessed then by the rest of the framework. The important thing for the implementation of the $expand stuff is to respect the permissions of the user.