Package Exports
- @elevatory/odata-typify-middleware
Readme
OData Typify Middleware
This middleware is used to extract Type information of Metadata-Calls.
Installation
npm install --save-dev @elevatory/odata-typify-middleware
Usage
Include the middleware in the ui5.yaml.
The middleware needs to run before middleware compression
No further configuration is needed
ui5.yaml
add the middleware in the server part under customMiddleware. Example:
server:
customMiddleware:
- name: "@elevatory/odata-typify-middleware"
beforeMiddleware: compressionpackage.json
Remember to also include it in your package.json under the ui5 dependencies
"ui5": {
"dependencies": [
"@elevatory/odata-typify-middleware"
]
}Trigger the middleware
Start your application with ui5 serve.
As soon as the tooling fetches the metadata-document from the server, the types will be parsed and the type files will be created.
If this does not happen, hold ctrl and click on the refresh button in the browser as the metadata-call might be cached and not triggering the middleware.
Configuration
The target directory for metadata can be configured
- name: "@elevatory/odata-typify-middleware"
beforeMiddleware: compression
configuration:
target: /src/metadata/ If the target directory does not exist, it will be created.
The target needs to be under the current working directory/project root.
If no target is given, the default /src/metadatat/ will be used.
HINT: Do not forget the trailing slashes for the directory!
Types
The types will be created under the project root in a folder (see configuration). The naming will be servicename.metadata.ts
Create types on demand
Run the command npx odata-typify to create types on demand.
You need to enter the username and password.
The types will be created based on the odata models provided in manifest.json and url in ui5.yaml for ui5-middleware-route-proxy