mongo-php-library icon indicating copy to clipboard operation
mongo-php-library copied to clipboard

draft: augment yaml definitions with test schema

Open nirinchev opened this issue 8 months ago • 0 comments

This is very much a POC, but I figured I'd open up a PR to get early feedback on the direction we're heading in.

For context, the devtools team wants to use the yaml definitions from the PHP driver to build an autocomplete experience for the aggregation pipelines in mongosh/compass. We've built a tool to convert the yaml to typescript definitions and it seems to be working well for the base case, but to polish it, we'd need to enhance the yaml definitions to allow us to generate more precise type definitions.

Here's a list of the high-level changes we're proposing (will be updated over time):

  • Update schema.json to remove duplicate $comment fields (since most json parsers are not happy about it).
  • Update all yaml definitions to add schema information for the test cases.
    • The schema shape matches SimplifiedSchema from the mongodb-schema package. This is a little bit verbose since it supports multiple types per field, even though the docs rarely have heterogeneous schemas.
    • Schema is generated automatically by crawling the docs website at the link pointed to by the test and then using the mongodb-schema package to infer a probabilistic schema from the example collection.
  • Removed a few tests that no longer seem to point to anything in the docs - e.g. firstN:Null and Missing Values.

nirinchev avatar Apr 07 '25 09:04 nirinchev