Skip to content

Generate a config yaml schema to better support config building/editing #374

Description

@anussel5559

Did you search for existing issues already?
Yup!

Is your feature request related to a problem? Please describe.
Nope

Describe the solution you'd like
Currently, when building or editing a slumber yaml configuration, there's no schema available - this isn't a huge deal, but leaves the user to their own devices as far as building a valid config file.

With a generated schema, the user's IDE can help guide them through building a valid config, and call out potential issues before they go to run the app.

Describe alternatives you've considered
None

Additional context
I looked a bit in to schemars to generate the schema from the Collection struct, but there was enough sprawl there that it made more sense to bring it up and talk about this potential feature more generally.

Activity

  1. LucasPickering commented on Sep 10, 2024

    @LucasPickering
    Owner

    What is the concrete workflow you'd like to enable with this? Currently when I start a new collection file I usually just copy and paste an example from the docs, or a previous file, and edit from there. It's definitely not great, so I'm curious how you think we can leverage a schema to make that process easier.

  2. anussel5559 commented on Sep 10, 2024

    @anussel5559
    ContributorAuthor

    Sure! So my thought is it'd be nice to not have to copy-paste. The IDE can be powerful if it knows what the schema is, it's mostly useless without it.

    Today, unless you copy-paste and don't make any mistakes when modifying that pasted bit of config, you'd never know that you may have an invalid config file until you startup the app when it parses. This feels slightly wasteful since the IDE could've told the user that well before running the app.

    Additionally, these configs make use of custom yaml tags, which the generic YAML validator knows nothing about (and thus complains) -
    image

    Ultimately this is a minor inconvenience and FAR from a boundary to successfully writing a valid config.

  3. LucasPickering commented on Sep 11, 2024

    @LucasPickering
    Owner

    @anussel5559 What would the artifact of schema generation look like? You mentioned schemars, are you picturing slumber spitting out a JSONSchema file? How would that get loaded into the IDE? How do we tell the IDE that slumber.yml should be parsed according to that schema?

  4. anussel5559 commented on Sep 11, 2024

    @anussel5559
    ContributorAuthor

    @LucasPickering yup, yaml schema is just JSON schema and that's what schemars would generate.

    There's a few ways the JSON schema can be associated to the yaml file to enable validation/hinting/docs/etc... (checkout this article), but likely the easiest way is to host the schema, and document that schema validation can be enabled by setting:

    # yaml-language-server: $schema=https://my.url.to/the/schema

    at the top of the config file.

  5. added
    qolImprovements that make usage smoother, without introducing new functionality
    on Sep 13, 2024
  6. LucasPickering commented on Sep 13, 2024

    @LucasPickering
    Owner

    Yeah I like this idea! I just opened a related feature #376 to add a subcommand slumber new, which would generate a new collection file. This file would include that comment at the top so users don't have to write it manually. And we could host the YAML file on the website, since that is already a process that generates static files in CI and hosts them.

    I'm going to do the slumber new thing, do you want to work on this issue?

  7. anussel5559 commented on Sep 13, 2024

    @anussel5559
    ContributorAuthor

    awesome! That makes a lot of sense. I'm definitely interested in helping out with this, likely after I get some solid movement on the collection ref stuff.

  8. LucasPickering commented on May 23, 2025

    @LucasPickering
    Owner

    @anussel5559 Took me a while to get to it but yesterday I played around with vscode-yaml and JSONSchema. It's really useful but there's a critical problem: JSONSchema doesn't support YAML tags in any way since tags don't exist in JSON. vscode-yaml has no extended support for it either.

    Having the schema definitely improved the experience of writing a collection so I like the idea. The only solution I can come up with for this is to ditch tags in favor of internally tagged enums, like so:

    login: !request
      method: GET
      url: https://website/login

    becomes this:

    login:
      type: request
      method: GET
      url: https://website/login

    The same change would have to be made for everything that uses tags. Obviously this would be a breaking change. I have plans for some other big breaking changes to the collection format, and I would implement an importer to upgrade people from the old format to the new one to make the transition pretty smooth, so I'm not opposed to making this change if it improves the user experience overall.

    What do you think?

  9. added a commit that references this issue on Jul 4, 2025
    7be134e
  10. LucasPickering commented on Jul 4, 2025

    @LucasPickering
    Owner

    I didn't forget about this! Just put up a PR to add this. It's part of a major collection format overhaul in 4.0, so it'll still be a bit before it gets released.

  11. added 12 commits that reference this issue on Jul 5, 2025
    afa83fb
    179d69d
    dbf726f
    3b28b27
    70e0cec
    94e3f59
    9fcb33b
    aa62bfa
    cb7b9fd
    9b6da67
    5d6a412
    ae634c9
  12. added 2 commits that reference this issue on Jul 30, 2025
    5499ccc
    54058d8
  13. added a commit that references this issue on Aug 9, 2025
    3fd83bd
  14. LucasPickering commented on Sep 12, 2025

    @LucasPickering
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    qolImprovements that make usage smoother, without introducing new functionality

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions