Skip to content

Add OData import support - #1649

Open
jahlen wants to merge 4 commits into
datacontract:mainfrom
jahlen:feature/odata-import
Open

jahlen wants to merge 4 commits into
datacontract:mainfrom
jahlen:feature/odata-import

Conversation

@jahlen

@jahlen jahlen commented Sep 22, 2026

Copy link
Copy Markdown

Adds OData 4.x import from CSDL XML or JSON, using URLs or local files. Supports selecting individual EntitySets or importing all advertised EntitySets, with authentication through the existing configuration system.

Sample usage

datacontract import odata \
  --service-root-url 'https://xmart-api-public-uat.who.int/refmart/' \
  --entity-set ref_country \
  --output datacontract.yaml

Sample generated datacontract

servers:
- server: source
  type: api
  customProperties:
  - property: apiType
    value: odata
  - property: odataVersion
    value: '4.0'
  - property: odataMetadataUrl
    value: https://xmart-api-public-uat.who.int/refmart/$metadata
  - property: format
    value: json
  location: https://xmart-api-public-uat.who.int/refmart/
schema:
- name: REF_COUNTRY
  physicalType: object
  customProperties:
  - property: odataEntitySet
    value: REF_COUNTRY
  - property: odataEntitySetUrl
    value: https://xmart-api-public-uat.who.int/refmart/REF_COUNTRY
  logicalType: object
  physicalName: REF_COUNTRY
  properties:
  - name: GEO_M49_CODE
    physicalType: Edm.String
    logicalType: string
    required: false
  - name: CODE_ISO_2
    physicalType: Edm.String
    logicalType: string
    required: false
    # More properties...

I would suggest to add "odata" as a separate server type in the ODCS so that it can be handled without custom properties. Meanwhile, I have used the server type "api".

Current limitations

  • This feature implements import only.

  • Complex types, collection-valued fields, entity or container inheritance, enum types, type definitions and
    types outside the table produce errors when used by selected schemas.

  • Tests pass (uv run pytest)

  • Code formatted (uv run ruff check --fix && uv run ruff format)

  • Docs updated (if relevant)

  • CHANGELOG.md entry added

@jschoedl

Copy link
Copy Markdown
Collaborator

Hi, thank you for the PR!

The docs and tests are pretty long, can you trim them down to what is realistically needed? You can take a look at how the other importers are documented and tested for reference. (In particular, descriptions of the development process like "odataEntitySet now belongs to each schema object" should not be part of the docs - what does "now" refer to?)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants