Skip to content

[BUG]: Quicktype not generating the correct descriptions from a CRD, seems to be merging them #2801

@cmwylie19

Description

@cmwylie19

We use quicktype to generate a json schema from a CRD but are noticing we are getting incorrect descriptions.

Issue Type

The issue is with the output

#!/bin/bash

set -e

curl -sSL https://gist.githubusercontent.com/mjnagel/c4cd6bef02e5c1746a938ec0699f06e5/raw/66ed5fb9fbca7bc36ef29c57ae067154d1567891/crd.yaml -o crd.yaml

yq '.spec.versions[0].schema.openAPIV3Schema' crd.yaml > schema.yaml

yq -o=json schema.yaml > schema.json

quicktype --lang schema \
  --src-lang schema \
  --top-level CustomResource \
  --out crd-schema.json \
  schema.json

If we look at this file, and search the description for network.allow labels description, we see the result should be The labels to apply to the policy.

 > yq ".spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.network.properties.allow.items.properties.labels.description" crd.yaml
The labels to apply to the policy

However, the schema generated has different labels.

> cat crd-schema.json| jq .definitions.Allow.properties.labels.description               
"Labels to match pods in the namespace to apply the policy to. Leave empty to apply to all pods in the namespace\nThe labels to apply to the policy\nDeprecated: use selector\nDeprecated: use remoteSelector\nThe remote pod selector labels to allow traffic to/from\nSpecifies attributes for the client.\nLabels to match pods to automatically protect with authservice. Leave empty to disable authservice protection\nConfiguration options for the mapper.\nAdditional annotations to apply to the generated secret, can be used for pod reloading with a selector\nAdditional labels to apply to the generated secret, can be used for pod reloading\nA template for the generated secret"

Context (Environment, Version, Language)

Input Format:
Output Language:

This affects the CLI and quicktype-core:23.2.6 npm library.

Version:

Description

Input Data

Expected Behaviour / Output

Current Behaviour / Output

Steps to Reproduce

curl -sSL https://gist.githubusercontent.com/mjnagel/c4cd6bef02e5c1746a938ec0699f06e5/raw/66ed5fb9fbca7bc36ef29c57ae067154d1567891/crd.yaml -o crd.yaml

yq '.spec.versions[0].schema.openAPIV3Schema' crd.yaml > schema.yaml

yq -o=json schema.yaml > schema.json

quicktype --lang schema \
  --src-lang schema \
  --top-level CustomResource \
  --out crd-schema.json \
  schema.json

# Get the original description
> yq ".spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.network.properties.allow.items.properties.labels.description" crd.yaml

# Get the generated description
> cat crd-schema.json| jq .definitions.Allow.properties.labels.description  

Possible Solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions