engine icon indicating copy to clipboard operation
engine copied to clipboard

Improve documents validation message

Open MattiSG opened this issue 3 years ago • 5 comments

Declaration validation does not consider an empty documents key as an error.

What happened

I tried to validate with npm run validate Example this malformed declaration:

{
  "name": "Example",
  "documents": { },
  "Terms of Service": {
    "fetch": "https://domain.example/tos",
    "select": "body"
  }
}

I got the following error:

data should not have additional elements

What I expected

An error in the style of:

`documents` cannot be empty, it should contain at least one of “Terms of Service”, “Imprint”…

MattiSG avatar Apr 22 '22 16:04 MattiSG

I believe documents can be empty (at least for now)

We needed to do this for OkCupid so that we stop tracking it but still keep track that it ever existed here. Let's discuss this in next planification then.

martinratinaud avatar Apr 25 '22 09:04 martinratinaud

After discussion, the best option seems to be to load both history files and declaration files so that closed and suspended services are made available. However, this has important consequences. For example, the name key is currently declared only in the main service declaration, not in its history. Allowing history files to be first-class declarations means duplicating this information, with a risk of divergence.

Instead of allowing a double declaration, the best way to improve the error messages seems to reformat it in the testing code instead of displaying to the contributor the message provided by the validator. Indeed, the error is:

{
  keyword: 'additionalProperties',
  dataPath: '',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'Terms of Service' },
  message: 'should NOT have additional properties'
} 

…we could thus give additional details on how to fix this error.

MattiSG avatar May 03 '22 12:05 MattiSG

@Manu1400 if you want to have a look, that could be a good way to improve the validator 🙂 @ndpnt could help you navigate the code if needed.

MattiSG avatar May 03 '22 13:05 MattiSG

can i work on this

shravan562 avatar Nov 27 '23 08:11 shravan562

@shravan562 of course, you're welcome to! In order to ensure a smooth implementation and review, before starting any work, please describe your implementation plan in this issue 🙂 Some knowledge of JSON-Schema validators will be important.

MattiSG avatar Dec 02 '23 18:12 MattiSG