-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document complete schema for firebase.json
#1409
Comments
Any news on this? |
Any updates? The provided link has a section called "The firebase.json file" that is not helpful. I still think that a json schema (like these ones) would be a better way to add documentation to this mysterious file. |
so this repo: https://github.com/SirWindfield/vscode-firebase-configuration-schema-plugin Is a plugin for Vscode that supplies it with a schema for firebase.json I agree that a schema is needed, at least for autocomplete benefits. That repo is outdated and archived, I do not believe it's maintained. However, it contains a valid and working schema for firebase.json. PS: I'm tempted to fork the repo and update it... does anyone else want to help out? |
@george43g if you do decide to contribute to that repo I would be happy to review your pull requests (I can't approve them, but I can at least give a Firebase stamp of approval). We actually have a few different needs around documenting the firebase.json schema:
|
@samtstern Yes, JSON Schema is the most standard way to support autocomplete in editors. IntelliJ uses this by default and VSCode can have support added by individual extensions as @george43g shows or by using popular plugins like the RedHat YAML plugin which pulls from JSON Schema store and provides both YAML and JSON autocomplete for all available schemas. |
Came here form #2233 (comment) Currently it very confusing to piece together globs of json from multiple locations without knowing the source of truth. Here are some of the scattered configs from the docs for reference: https://firebase.google.com/docs/cli#the_firebasejson_file Also as @jthegedus pointed out JSON schemas for popular plugins are embedded in IntelliJ (see https://www.jetbrains.com/help/idea/json.html#ws_json_using_schemas) using SchemaStore (see https://www.schemastore.org/json/) |
I'd like to add, having a utility function that validates a Firebase configuration would also be helpful (whether by the json schema or otherwise). I implemented a tool recently that reads a provided Firebase config and needed to implement a large Joi validation to check to ensure when Firebase Hosting Additionally, it appears there are multple places in this repo where functions are validated but with different rules. |
If anyone is still waiting on this, you can check out a JSON Schema for This is just our first attempt to define the schema officially so it's possible that there are some configurations allowed in the real world that disagree with that file, please let me know if you find anything like that! Right now if we find JSON schema errors it's only exposed in |
This is a great step @samtstern cheers! A use case that I am not sure JSON Schemas can cover is when a rewrite rule is defined to rewrite to a function, but the
Currently even if I were to use this JSON Schema (and I will) to validate a config, I still have to hardcode the default values in my tool, like |
@jthegedus yeah the implicit defaults for products like Functions are definitely a bit of a problem here. Can you explain why you'd need to hardcode |
Sorry, that example goes back to my prior comments above. I've built
Some missing items from the schema (I realise it is a first release):
|
An alternative to my above suggestiong would be to have all the default config values defined in a single JS object so consumers could object spread |
@jthegedus wow good eye! If you want to update the schema, you could send a PR here. The TypeScript is the source of truth: I agree we need to centralize the defaults. One of the issues is that they're a bit context dependent! For instance it's not true to say that the default for |
In the context of my usage I only look for The context-dependent implementation does make this difficult. |
It would be great if you could allow the firebase.json {
"$schema": "./node_modules/firebase-tools/schema/firebase-config.json",
"hosting": [...]
} similar to what turborepo does, as it's great for validation. |
Pointing to the schema file from {
"$schema": "https://raw.githubusercontent.com/firebase/firebase-tools/master/schema/firebase-config.json",
"functions": {
"source": "./"
},
// ...
} |
can you guys publish this? |
Originally suggested by @matheo here:
#1303 (comment)
We should document the complete schema of
firebase.json
in both human-readable and machine-readable formats. This file has expanded a lot and it's not always clear what's there and what the defaults are.The text was updated successfully, but these errors were encountered: