Repository navigation
Fix skills.sh.json to match the skills.sh schema - #255
reidbaker-agent wants to merge 1 commit into
Conversation
Rename groups to groupings and point $schema at the live schema URL. Update the lint test and generator README to match, and check that the file only uses keys the schema allows. Fixes flutter#253
There was a problem hiding this comment.
Code Review
This pull request updates the schema URL and renames the 'groups' property to 'groupings' in 'skills.sh.json' to align with the latest schema definition. Corresponding updates are made to the generator's documentation and the lint tests, which now also validate that only allowed keys are present. The review feedback suggests enhancing the test assertions by explicitly verifying the types of the 'groupings' list and the required 'skills' property to prevent cryptic type errors during parsing.
| final groups = (skillsShJson['groupings'] as List<Object?>) | ||
| .cast<Map<String, Object?>>(); |
There was a problem hiding this comment.
To prevent cryptic TypeErrors when parsing skills.sh.json (e.g., if groupings is missing, null, or not a list of maps), it is safer to explicitly assert the type of groupings and its elements using expect before casting.
| final groups = (skillsShJson['groupings'] as List<Object?>) | |
| .cast<Map<String, Object?>>(); | |
| expect(skillsShJson['groupings'], isA<List<Object?>>()); | |
| final groupingsList = skillsShJson['groupings'] as List<Object?>; | |
| expect(groupingsList, everyElement(isA<Map<String, Object?>>())); | |
| final groups = groupingsList.cast<Map<String, Object?>>(); |
| expect( | ||
| group.keys, | ||
| everyElement(isIn(['title', 'description', 'skills'])), | ||
| ); |
There was a problem hiding this comment.
While we validate that the keys of each group only contain allowed properties, we should also explicitly assert that the required skills property is present and is a list. This provides a clear failure message if a group is missing its skills list, rather than throwing a TypeError later in _collectUniqueGroupedSkills.
| expect( | |
| group.keys, | |
| everyElement(isIn(['title', 'description', 'skills'])), | |
| ); | |
| expect( | |
| group.keys, | |
| everyElement(isIn(['title', 'description', 'skills'])), | |
| ); | |
| expect(group['skills'], isA<List<Object?>>()); |
reidbaker
left a comment
There was a problem hiding this comment.
Examples from other repos that use groupings not groups.
https://github.com/expo/skills/blob/main/skills.sh.json
https://github.com/NVIDIA/skills/blob/main/skills.sh.json
| import 'package:test/test.dart'; | ||
|
|
||
| const String _expectedSkillsShSchema = | ||
| 'https://skills.sh/schemas/skills.sh.json'; |
There was a problem hiding this comment.
Best I can tell this url did not exist.
|
@johnpryan would you like me to wait on your reviews for this repo? |
Fixes #253
skills.sh.jsonusedgroups, but the skills.sh schema expectsgroupingsand setsadditionalProperties: false. Its$schemaURL also returned a 404. This change:groupstogroupings.$schemaathttps://skills.sh/schemas/skills.sh.schema.json.tool/generator/test/lint_skills_test.dartto readgroupings, expect the new URL, and fail on any top-level or group key the schema does not allow.hiddenas a validnotGroupedvalue (the schema allows onlytopandbottom).No other mismatches:
notGrouped: "bottom"and every group'stitle,descriptionandskillsmatch the schema.Validation against the live schema with Python
jsonschema(Draft 2020-12, as the schema declares):dart analyze --fatal-infos,dart formatanddart testpass intool/generator.