omissis/go-jsonschema

Incorrect root type name generation

felixjung opened this issue · 1 comments

When generating code from a YAML schema definition, the automatically generated struct name for the root type has a trailing Yaml suffix because the file extension isn't trimmed correctly from the filename.

Example

Input

# mySchema.yaml

"$schema": "http://json-schema.org/draft-04/schema#"
"$id": "https://example.com/yaml_root_type_name"

type: object
properties:
  foo:
    type: string

Expected Output

// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.

package test

type MySchema struct {
	Foo *string `json:"foo,omitempty" yaml:"foo,omitempty"`
}

Actual Output

// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.

package test

type MySchemaYaml struct {
	Foo *string `json:"foo,omitempty" yaml:"foo,omitempty"`
}

Fixed in #52