Skip to content
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

Generated types for patternProperties are any #230

Open
stevejpurves opened this issue Nov 21, 2024 · 0 comments
Open

Generated types for patternProperties are any #230

stevejpurves opened this issue Nov 21, 2024 · 0 comments

Comments

@stevejpurves
Copy link

stevejpurves commented Nov 21, 2024

Hi There!

I have a working schema, where I have an object with patternProperties, defined as:

# $schema: https://json-schema.org/draft/2020-12/json-schema-core.html
title: My Schema
type: object
additionalProperties: false
required:
  - api
properties:
  api:
    type: object
    required:
      - myCDNSigningInfo
    properties:
      myCDNSigningInfo:
        type: object
        patternProperties:
          '^[a-zA-Z0-9_.-]+$': { $ref: '#/$defs/myCDNSigningInfo' }
        secret: true
$defs:
  CDNSigningInfo:
    type: object
    additionalProperties: false
    properties:
      hostname:
        type: string
      keyName:
        type: string
      key:
        type: string

But the types generated using npx @app-config/cli generate command are very loose:

export interface Config {
  api: API;
}

export interface API {
  myCDNSigningInfo: { [key: string]: any };
}

Is there a way to improve this type generation or alternatively a different way to define my schema to get better typing?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant