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

Inline enums are not translated #9

Open
Marwes opened this issue Jan 28, 2018 · 2 comments
Open

Inline enums are not translated #9

Marwes opened this issue Jan 28, 2018 · 2 comments

Comments

@Marwes
Copy link
Owner

Marwes commented Jan 28, 2018

From https://github.com/Marwes/schemafy/blob/master/tests/vega/vega.json

{
    "$ref": "#/definitions/TopLevelExtendedSpec",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "BarConfig": {
            "additionalProperties": false,
            "properties": {
                "cursor": {
                    "enum": [
                        "auto",
                        "default",
                        "none"
                    ],
                    "type": "string"
                },
                "type": "object"
            }
        }
    }
}

BarConfig gets assigned the type Option<String> instead of a specific enum type.

@waywardmonkeys
Copy link

This is one that I noticed happening a lot as well.

@Marwes
Copy link
Owner Author

Marwes commented Jan 28, 2018

Inline structs are handled at

schemafy/src/lib.rs

Lines 351 to 360 in 7871e21

SimpleTypes::Object if !typ.properties.is_empty() => {
let name = format!(
"{}{}",
self.current_type.to_pascal_case(),
self.current_field.to_pascal_case()
);
let tokens = self.expand_schema(&name, typ);
self.types.push((name.clone(), tokens));
name.into()
}
.

Enums need to do the same thing, generate a new name expand the schema and push it to self.types (which gets emitted later on).

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

No branches or pull requests

2 participants