quarkiverse / quarkus-roq

An extension to generate/publish static pages from your Quarkus web-app
Apache License 2.0
2 stars 3 forks source link

[roq-data] type-safe class/record binding to data #18

Open ia3andy opened 1 week ago

ia3andy commented 1 week ago

Allow the user to define class and records to bind to the json/yaml data. If the data doesn't meet the requirements it should fail at build-time.

maxandersen commented 1 week ago

just to capture what we discussed:

imagine you have something like _data/extensions.yaml

categories:
  - category: Core
    cat-id: core
    extensions:
      - name: Configuration
        description: "Included: MicroProfile Configuration via SmallRye"
      - name: Logging
        description: "Included: centralized log management for Quarkus"
      - name: ArC
        description: "Build time CDI dependency injection"
        labels:
        - arc
        - cdi
        - dependency-injection
        - di
        groupId: io.quarkus
        artifactId: quarkus-arc
  - category: Web
    cat-id: web
    extensions:
      - name: Netty
        description: "Netty is a non-blocking I/O client-server framework. Used by Quarkus as foundation layer."
        groupId: io.quarkus
        artifactId: quarkus-netty
      - name: RESTEasy JAX-RS
        description: "REST framework implementing JAX-RS and more"
        labels:
        - resteasy
        - jaxrs
        - web
        - rest
        groupId: io.quarkus
        artifactId: quarkus-resteasy

then you should in a template be able to declare you want access to extensions as a bean/property. Possibly it would be data.extensions if the usease is a blog generation:

then this should build at build time:

{#for ext in data.extensions} 
       <li>{ext.Category}</li>  
{/for} 

but this should fail:

{#for ext in data.extensions} 
       <li>{ext.notThere}</li>  
{/for} 

similar if there is a map there should be validation that you don't refer to a property that does not exist on any of those elements.

melloware commented 3 days ago

Looks like this is what @gsmet was talking about for Jackson reading of Yaml or Json: https://github.com/quarkiverse/quarkus-github-app/blob/main/runtime/src/main/java/io/quarkiverse/githubapp/runtime/github/GitHubConfigFileProviderImpl.java