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

Some valid CRDs are not rendered #157

Closed
muvaf opened this issue Dec 3, 2021 · 5 comments · Fixed by #160
Closed

Some valid CRDs are not rendered #157

muvaf opened this issue Dec 3, 2021 · 5 comments · Fixed by #160

Comments

@muvaf
Copy link

muvaf commented Dec 3, 2021

Linking an issue from original repo crossplane-contrib/provider-jet-aws#134

I couldn't immediately find out why. This one for example doesn't have an obvious issue I could spot in its schema.

@AaronME
Copy link

AaronME commented Dec 6, 2021

Did some basic trouble-shooting. It looks like the schema for AutoScalingGroup includes a field for "tags" which is defined as an "array" and the items schema says it should be an array of "object" types.

However, properties field of this array is set to null, which is breaking the page at

let propKeys = Object.keys(props);

Including the relevant "tags" schema below:

"tags":
{
    "ID": "",
    "Schema": "",
    "Ref": null,
    "Description": "",
    "Type": "array",
    "Nullable": false,
    "Format": "",
    "Title": "",
    "Default": null,
    "Maximum": null,
    "ExclusiveMaximum": false,
    "Minimum": null,
    "ExclusiveMinimum": false,
    "MaxLength": null,
    "MinLength": null,
    "Pattern": "",
    "MaxItems": null,
    "MinItems": null,
    "UniqueItems": false,
    "MultipleOf": null,
    "Enum": null,
    "MaxProperties": null,
    "MinProperties": null,
    "Required": null,
    "Items":
    {
        "Schema":
        {
            "ID": "",
            "Schema": "",
            "Ref": null,
            "Description": "",
            "Type": "object",
            "Nullable": false,
            "Format": "",
            "Title": "",
            "Default": null,
            "Maximum": null,
            "ExclusiveMaximum": false,
            "Minimum": null,
            "ExclusiveMinimum": false,
            "MaxLength": null,
            "MinLength": null,
            "Pattern": "",
            "MaxItems": null,
            "MinItems": null,
            "UniqueItems": false,
            "MultipleOf": null,
            "Enum": null,
            "MaxProperties": null,
            "MinProperties": null,
            "Required": null,
            "Items": null,
            "AllOf": null,
            "OneOf": null,
            "AnyOf": null,
            "Not": null,
            "Properties": null,
            "AdditionalProperties":
            {
                "Allows": true,
                "Schema":
                {
                    "ID": "",
                    "Schema": "",
                    "Ref": null,
                    "Description": "",
                    "Type": "string",
                    "Nullable": false,
                    "Format": "",
                    "Title": "",
                    "Default": null,
                    "Maximum": null,
                    "ExclusiveMaximum": false,
                    "Minimum": null,
                    "ExclusiveMinimum": false,
                    "MaxLength": null,
                    "MinLength": null,
                    "Pattern": "",
                    "MaxItems": null,
                    "MinItems": null,
                    "UniqueItems": false,
                    "MultipleOf": null,
                    "Enum": null,
                    "MaxProperties": null,
                    "MinProperties": null,
                    "Required": null,
                    "Items": null,
                    "AllOf": null,
                    "OneOf": null,
                    "AnyOf": null,
                    "Not": null,
                    "Properties": null,
                    "AdditionalProperties": null,
                    "PatternProperties": null,
                    "Dependencies": null,
                    "AdditionalItems": null,
                    "Definitions": null,
                    "ExternalDocs": null,
                    "Example": null,
                    "XPreserveUnknownFields": null,
                    "XEmbeddedResource": false,
                    "XIntOrString": false,
                    "XListMapKeys": null,
                    "XListType": null,
                    "XMapType": null
                }
            },
            "PatternProperties": null,
            "Dependencies": null,
            "AdditionalItems": null,
            "Definitions": null,
            "ExternalDocs": null,
            "Example": null,
            "XPreserveUnknownFields": null,
            "XEmbeddedResource": false,
            "XIntOrString": false,
            "XListMapKeys": null,
            "XListType": null,
            "XMapType": null
        },
        "JSONSchemas": null
    },
    "AllOf": null,
    "OneOf": null,
    "AnyOf": null,
    "Not": null,
    "Properties": null,
    "AdditionalProperties": null,
    "PatternProperties": null,
    "Dependencies": null,
    "AdditionalItems": null,
    "Definitions": null,
    "ExternalDocs": null,
    "Example": null,
    "XPreserveUnknownFields": null,
    "XEmbeddedResource": false,
    "XIntOrString": false,
    "XListMapKeys": null,
    "XListType": null,
    "XMapType": null
},

@AaronME
Copy link

AaronME commented Dec 6, 2021

This code block assumes that all "object" types have properties:

doc/template/doc.html

Lines 95 to 109 in cb01d9f

let props = property.Properties || {};
let type = property.Type;
if (type === 'array') {
const itemsSchema = property.Items.Schema;
if (itemsSchema.Type !== 'object') {
type = `[]${itemsSchema.Type}`;
} else {
console.log({ property, itemsSchema });
schema = itemsSchema;
props = itemsSchema.Properties;
type = `[]object`;
}
}
let propKeys = Object.keys(props);

@AaronME
Copy link

AaronME commented Dec 6, 2021

@muvaf Could you confirm whether crdsdev needs to accommodate this type of schema or if this might be a bug in the generated type?

@hasheddan
Copy link
Member

@AaronME if the k8s api server accepts it then we should be accommodating it here 👍🏻 I'm working on some fixes

@muvaf
Copy link
Author

muvaf commented Dec 7, 2021

@AaronME thanks for debugging! Seems like that field has the type of []map[string]*string, which might be why.

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

Successfully merging a pull request may close this issue.

3 participants