Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract common ag inspection info into its own schema #584

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

rhofvendahl
Copy link
Collaborator

A number of agricultural inspection schemas (FoodGradeInspection, AgricultureInspectionGeneric, several more in the works) share several common properties. The ideal solution would be to create a base AgricultureInspection schema which other inspections extend, but as far as I know that functionality isn't currently supported (see issue 162, issue 277).

An alternative to inheritance is to create a schema which includes properties common to multiple inspection schemas and include that in each. This PR implements that approach by creating an AgricultureInspectionCommonInfo schema and refactoring AgricultureInspectionGeneric (renamed from AgricultureInspectionReport for clarity) and FoodGradeInspection to make use of this common info schema.

@rhofvendahl rhofvendahl changed the title chore: extract common ag info into own schema Extract common ag inspection info into its own schema Oct 11, 2022
@@ -245,7 +261,7 @@ example: |-
"Organization"
],
"name": "Ace Foodstuffs",
"description": "Agricultural goods shipping & distribution",
"description": "Ag goods shipping & distribution",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a step in the wrong direction. "Ag" is not as clear as "Agriculture".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

@BenjaminMoe
Copy link
Contributor

https://github.com/w3c-ccg/traceability-vocab/actions/runs/3223964212/jobs/5274591511

        "estimatedCharges": "$135.00"
      } 
       [
        {
          keyword: 'enum',
          dataPath: '/commonInfo/type/0',
          schemaPath: '#/properties/type/oneOf/0/items/enum',
          params: { allowedValues: [Array] },
          message: 'should be equal to one of the allowed values'
        },
        {
          keyword: 'type',
          dataPath: '/commonInfo/type',
          schemaPath: '#/properties/type/oneOf/1/type',
          params: { type: 'string' },
          message: 'should be string'
        },
        {
          keyword: 'const',
          dataPath: '/commonInfo/type',
          schemaPath: '#/properties/type/oneOf/1/const',
          params: { allowedValue: [Array] },
          message: 'should be equal to constant'
        },
        {
          keyword: 'oneOf',
          dataPath: '/commonInfo/type',
          schemaPath: '#/properties/type/oneOf',
          params: { passingSchemas: null },
          message: 'should match exactly one schema in oneOf'
        }
      ]

      51 |         const isValid = ajv.validate(s.$id, input);
      52 |         if (!isValid) {
    > 53 |           console.error(s.$linkedData.term, '\n', s.example, '\n', ajv.errors);
         |                   ^
      54 |         }
      55 |
      56 |         return true;

      at __tests__/schemas-sanity.test.js:53:19
          at async Promise.all (index 44)
      at Object.<anonymous> (__tests__/schemas-sanity.test.js:37:18)

@BenjaminMoe
Copy link
Contributor

__tests__/schemas-sanity.test.js

@BenjaminMoe
Copy link
Contributor

#586

@brownoxford
Copy link
Collaborator

OK to merge once Jest tests are all passing.

Copy link
Contributor

@BenjaminMoe BenjaminMoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay to merge once passing Jest tests

delegateOf:
title: Delegate Of
description: Inspector is acting on behalf of this entity (common with many ag. inspections).
$ref: ./Entity.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will likely create other issues, but not a blocker.

@brownoxford brownoxford merged commit 2e5713e into w3c-ccg:main Oct 11, 2022
@brownoxford brownoxford deleted the feat/ag-inspection-refactor branch October 11, 2022 18:13
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.

6 participants