glideapps / glideapps/quicktype

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

Open
#2,801 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

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

```bash
#!/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](https://gist.githubusercontent.com/mjnagel/c4cd6bef02e5c1746a938ec0699f06e5/raw/66ed5fb9fbca7bc36ef29c57ae067154d1567891/crd.yaml), and search the description for network.allow labels description, we see the result should be `The labels to apply to the policy`.

```bash
> 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.

```bash
> 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

```bash
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.