Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

use a different schema for a product #1412

Open
voltumna opened this issue May 3, 2022 · 5 comments
Open

use a different schema for a product #1412

voltumna opened this issue May 3, 2022 · 5 comments
Assignees

Comments

@voltumna
Copy link

voltumna commented May 3, 2022

Dear all,
I created 2 schemas for products, and that worked like a charm following the instructions in https://grid.hyperledger.org/docs/0.3/creating_schemas.html.
I have tried to create different products but they all use one schema, the gs1_product, and I do not understand how one can use different product schemas.
Is there some help or example on how that could work?
thank you
Maurizio

@voltumna
Copy link
Author

voltumna commented May 9, 2022

Hello? I would love some feedback

@shannynalayna shannynalayna self-assigned this May 9, 2022
@shannynalayna
Copy link
Contributor

Hi @voltumna 👋🏻 Sorry we missed your question initially, but I'm taking a look now and will update you with an answer!

@voltumna
Copy link
Author

voltumna commented May 9, 2022

Thank you, looking forward to your answer :)

@shannynalayna
Copy link
Contributor

So, I believe that if you are using a YAML file for the product itself, Grid will assume that you are creating a GS1 namespaced product. Therefore, the schema that it attempts to grab is the gs1_product schema. You can see that happening from the CLI here: https://github.com/hyperledger/grid/blob/main/cli/src/actions/product.rs#L380. Otherwise, product files can be submitted as XML files, which are validated for being GridTradeItems in the expected format

@voltumna
Copy link
Author

voltumna commented May 9, 2022

Thank you for the answer, I tried both: xml and yaml, but both used the gs1_product.yaml but that I feel is because there is something else missing: if I create a product schema called myschema_product.yaml, then I would presume that it will be imposed if my product uses the myschema namespace, but how do I specify the myschema namespace in the xml of the product? do you have an example?
I have not tried yet, but I noticed that in the instructions (i stumbled by chance), I seem to be able to mention the schema with the --file option:

root@gridd-alpha:/# grid product create \
--owner myorg \
--file product.xml \
--file additional_attributes.yaml

from
https://grid.hyperledger.org/docs/0.3/creating_products_with_nonstandard_attrs.html

What do you think?
Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants