Spectral rule to access keys rather than values

I’m writing a rule to check that our APIs adhere to our naming guidelines. Checking the parameters for the request is easy because they have a “name” property! However I’m not sure how to access the names of the response fields since these are keys inside the components.schemas.*.properties and the fieldname I need is the key of the entry.

The field I want is this: https://github.com/Nexmo/api-specification/blob/master/definitions/verify.yml#L520

I’ve considered going up a level and getting all the objects and iterating, but then how can I return the error information for each field? Advice gratefully received!

Hey Lornajane!
What you seem to be looking for is ~, the character that in JSON Path expressions stands for keys.
The JSON Path expression could look as follows $..components.schemas.*.properties[*]~.
Please, let me know whether the above JSON path expression matches the portions of the document you want to lint. :slight_smile:

1 Like

Thank you! This is EXACTLY what I needed :slight_smile: