-
Notifications
You must be signed in to change notification settings - Fork 31
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
Separate JSON schema for each component #1283
Conversation
Should be easy enough to test locally with
Should not be needed - the whole I'll add a list of TODOs I think we should look into after this:
|
Quickly looked over a few components and there are likely many missing textResourceBinding properties. Not sure if this is up-to-date anymore but: https://altinndevops.slack.com/archives/C045EB3JA9X/p1675931223052249?thread_ts=1675871625.344949&cid=C045EB3JA9X |
@bjosttveit I think we should merge this as-is, to let @nkylstad carry on - and in a separate job we should look over our text resource bindings for each component and properly type them in both TypeScript and in this schema. Would be a nice way to start off #832, maybe. |
Then maybe switch |
Sure, I have set |
Har man glemt denne settingen som kom nylig på Radiogroup? https://github.com/orgs/Altinn/projects/39/views/2?pane=issue&itemId=30673603 |
Ja! Glemt er kanskje å ta litt hardt i gitt at PR'en for den radio-endringen ble merget i går 😅 Men tar det med! |
Vi har vel også en "PrintButton"? Brukes i anonym oppstartsveileder. |
…re named correctly
… in the path to layout.schema.v2.json, sorting components
…s is good practice)
…into chore/update-component-schemas
Marking this as draft because I'm working on adding support for the 3 missing components here. After that is done, I want to compare the results of validating against this file and the old one on existing apps to make sure we know of every case where this might break an existing configuration. |
Kudos, SonarCloud Quality Gate passed! |
Hi! I've created Hugo shortcode scripts to automatically list each component's properties in the documentation and have come across a few issues:
|
@thestokkan Oh, it's possible we're working on reaching the same goals, then.. 🙈 I'm currently working on #832 now, and I'm creating a code generator that will generate both these JsonSchema files (making this PR unnecessary) and our internal TypeScript types. I'm thinking it should also be possible for that code generator to generate some documentation in the form of markdown files as well. Instead of manually making sure every component property of all current components were correct in this PR, I opted to start implementing #832 instead, so that's why this PR has been dormant for a while. |
@olemartinorg Aha 😅 I was aware of someone working on autogenerating the schema files, but not documentation (I asked @nkylstad before the holiday if anyone was working on autogenerating documentation from the schema files and she said no 🤷🏻♀️). I just merged a PR with the shortcode files (Altinn/altinn-studio-docs#1022) and a separate PR with drafts for template files and a component example using the shortcode (Altinn/altinn-studio-docs#1021) (I'm going to ask for feedback on the template on Slack). Why don't you have a look and then we figure out the best solution? I'm a Hugo newbie so you can most likely create something more robust. 😉 Edit: I saw the below comment on your PR just now. This is a bit strange, as I believe @TheTechArch knew at that point what I was working on. Maybe there's been a misunderstanding somewhere.
|
@thestokkan Very interesting! 🤔🤩 I still have some work left on #832, but I would love to work together with you and @nkylstad to make something work. I believe JsonSchema is just a bit too complicated to parse for this purpose, so I think we can generate a new format that can be used to automatically create markdown for component properties docs, and also for generating a configuration Altinn Studio can use to get some hints at what is needed for the component configuration. If that spins out into 4 different formats (our internal TypeScript types, the JsonSchema used for validation + vscode hinting, a simplified structure for documentation, and another format for Studio) that should be easily possible with the code generator I'm making. So, I suggest we work together on this one! 🙏 I'll continue working on #832, but I'll make sure to reach out when that's more stable. |
@olemartinorg Sounds great! Question is, should I keep the shortcode for now until we have something else? I've used the json schema links from this PR waiting for it to be merged. Not sure if that is ok as a temporary solution? |
@thestokkan I suspect the new JsonSchema will look radically different, so even though parsing this JsonSchema was possible, parsing every possible valid varation in JsonSchema is close to impossible - so using the JsonSchema itself for parsing to docs makes for a solution that will easily break, and/or limit our creativity when extending the schema.. The same thing goes for using the schema as a basis for an editor (i.e. Studio). So yeah, keep it as-is, if you have other things to work on, and we'll touch base to figure out a longer-lasting solution. 🙌 Btw, I looked briefly at the hugo shortcode, and it did not look like newbie code to me! 🤷 Nifty solution! 🤩 |
The new (generated) JsonSchema is on its way in #1406. Closing this PR, and we'll figure out a solution to the docs and Studio side of things discussed above. |
Description
layout.schema.v1.json
into separate schemas for each component, which are referenced from a newlayout.schema.v2.json
common-defs.schema.json
file, which only contains definitions.showAsSummary
,hidden
,grid
andpageBreak
, as I'm not sure if there are any components that do not support these. Feel free to comment/suggest changes here.dataModelBindings
andtextResourceBindings
as component specific as possible, but it is possible I have missed/forgotten something - again feel free to update/comment.layout.schema.v2.json
options/optionsId
properties for selection components. I'm sure it's possible to create a conditional schema where:options
is required whenoptionsId
is not presentoptionsId
is required whenoptions
is not presentHowever I was not able to get this working. As it's not a feature of the current schema either I left it out for now.
I'm also slightly unsure of whether the relative paths to the linked schemas work in the case of schemas in a different folder. It works when I test it locally, but I imagine it might be different once this is published to CDN - we might have to use complete URLs for schemas that do not live in the same folder 🤔
I will also need some help updating any pipelines/actions that publish schemas to CDN if there is a need for that.
Related Issue(s)
Verification/QA
src/layout/layout.d.ts
andlayout.schema.v1.json
, and these are all backwards-compatiblekind/*
label to this PR for proper release notes grouping