frictionlessdata / datapackage-php

A php library for working with Data Package.
MIT License
10 stars 10 forks source link

Profile API feedback #20

Closed roll closed 7 years ago

roll commented 7 years ago

Overview

Based on this readme listing I'm adding feedback based on existent implementations and expected lib user competencies (as we target many almost non-tech users - publisher, data wranglers etc).

use frictionlessdata\datapackage;

// register custom datapackage or resource classes which can override / extend core classes
// these custom classes run a test against the schema to decide whether to handle a given descriptor or not
Factory::registerDatapackageClass("my\\custom\\DatapackageClass");
Factory::registerResourceClass("my\\custom\\ResourceClass");

// register custom profiles and related schemas for validation
Registry::registerSchema("my-custom-profile-id", "path/to/my-custom-profile.schema.json");

Profiles handling

Just want to share how we handle it in Python/Javascript. After all back and forth with profiles on specs and libs level for now we have a simple system for main libs (and Ruby is syncing). It's described here - https://github.com/frictionlessdata/datapackage-rb/issues/31#issuecomment-310603664- and based on descriptor.profile which could be:

That's the very lightweight approach which could be considered instead of registering classes/jsonschemas etc (which could be like too difficult for ordinary users if I've got current API correctly)

Schema term

Minor thing (if naming could be minor) but across all implementations we're leaning toward following terminology:

OriHoch commented 7 years ago

it is working using profile as you describe, but I guess it should be made clearer in README, I'll add a comment to #22 to do that

I removed the examples you referred to from the README - they are meant for more advanced use case, if you want to add custom logic based on profile, in #22 I'll update the README with full API details and make it clear it's for advanced use only.

Regarding terms, I opened an issue to handle it there - #24