Repository: go-swagger/go-swagger (go)

Issue:
Pointer convertors for enum types are not generated.
No methods converting enum literal to a pointer value of same type are generated by current CLI.

Pull request description:
enhancement: added enum pointer factory to codegen
enhancement: added enum pointer factory to codegen

Makes enum values more tractable when used in models which use pointers.

* generates a New{EnumType}(value {EnumType}) *{EnumType} function
* only support string enums (the only type for which we generate enum const atm)

* fixes #2482

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>

Patch:
diff --git a/generator/bindata.go b/generator/bindata.go
index 226f0d13..2d2d7a3a 100644
--- a/generator/bindata.go
+++ b/generator/bindata.go
@@ -12,7 +12,7 @@
 // templates/header.gotmpl (432B)
 // templates/markdown/docs.gotmpl (14.106kB)
 // templates/model.gotmpl (700B)
-// templates/schema.gotmpl (6.259kB)
+// templates/schema.gotmpl (6.529kB)
 // templates/schemabody.gotmpl (14.007kB)
 // templates/schemaembedded.gotmpl (1.006kB)
 // templates/schemapolymorphic.gotmpl (2.125kB)
@@ -353,7 +353,7 @@ func templatesModelGotmpl() (*asset, error) {
 	return a, nil
 }
 
-var _templatesSchemaGotmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x58\xdd\x6e\xdc\xb6\x12\xbe\xf7\x53\xcc\xf1\xf1\x39\x90\x0c\x47\xdb\xe6\xaa\x4d\xe1\x0b\x3b\x4e\xea\x14\x68\x1c\xc4\x69\x02\x34\x0d\x02\xae\x38\x5a\x31\xa1\x48\x85\xa4\x1c\x6f\x85\x7d\xf7\x82\x22\xa5\xa5\xb4\xdc\xb5\x5d\xa7\x40\xd0\xd6\x57\x6b\x91\x1c\xce\x7c\xf3\xfb\xb1\x6d\x1f\x00\x2b\x80\x08\x0a\xd9\x33\x7d\x4a\x34\xbe\x5a\xd6\x68\x7f\x3f\xb9\xae\xa5\x32\x48\x21\x11\xd2\xd8\x0f\x97\x4d\x8d\xea\x84\x33\xa2\x53\x58\xad\xf6\x00\xec\x59\x83\x55\xcd\x89\x41\xd8\xd7\x79\x89\x15\x79\x21\xf9\xb2\x92\xaa\x2e\x59\xbe\x0f\x99\xdd\x67\x77\x21\xd7\x68\xaf\x19\x49\x71\x42\x8c\xbd\xae\x6d\xa1\x26\x3a\x27\x9c\xfd\x8e\x90\x3d\x27\x15\xc2\x6a\x65\xbf\xae\xc5\xdb\x7d\x97\xdd\x15\x56\x41\x27\xbb\x6d\x67\x87\xf0\x54\xaa\x4e\x88\x06\x8a\x39\x27\x0a\x29\x10\x0d\x07\x0a\x0b\x90\x02\xb4\xac\x10\xa4\x29\xd1\x6d\x3a\x82\x0f\x8d\x36\xfd\x4e\x30\x25\x3a\x05\x88\x06\x02\x0b\xc9\x89\x58\xc0\x7b\x62\xb5\x43\xfa\xde\x9f\xc0\x6c\x91\xb9\x5d\x27\x70\x0c\xa7\x19\x3c\x97\x50\xa1\x29\x25\x05\x5d\x12\xce\x61\x8e\xa0\xb0\xbf\x3c\x03\x38\x9c\x0d\xf0\x38\x9b\x07\x58\xbb\xef\x30\x36\x6c\xee\x17\x2f\x51\xb1\x0e\x00\x15\x18\xf7\xa6\x44\xd1\x69\xd9\xe9\xb4\xbe\xc6\xaa\x5b\xaf\xa1\xf6\x9a\x52\x2c\x98\x40\x28\x48\x6e\xa4\x5a\x7a\x25\x35\x7c\x66\xa6\x04\x53\x32\xed\xa4\x64\xa1\x82\x28\x68\xc4\x49\x4f\xaa\x39\x52\x8a\x74\xbb\x9f\xfb\x1d\x53\x27\x87\x96\x4b\x65\x65\x3d\x96\x55\xcd\xf1\xfa\x62\xfe\x01\xf3\x2e\x8e\x5e\x35\x35\xef\x22\xec\x84\x52\x66\x98\x14\x84\xbf\x50\xb2\x46\x65\x18\xea\xde\xf0\x57\x17\x67\x17\x49\xa1\x90\xa6\x8f\xa0\x24\x82\x72\x84\x9c\x68\x04\x59\x80\x6e\xe6\x9d\x37\x98\x28\x51\x31\xc3\xc4\x02\x0a\x25\x2b\xb0\x40\x3a\x3f\x75\x06\xc7\xa4\x1f\x01\xd3\xba\x41\xf8\xef\xc3\x87\x0f\xbf\xe9\x61\xf0\x1e\xb1\x96\xfb\xc8\xeb\x63\x92\x15\xe0\x63\x7f\x48\x06\xab\xde\xb0\xaf\x6d\x7b\xa3\xa3\x01\x6c\x97\x05\x0d\x7f\x8c\x3d\xef\x90\x3c\x95\x74\xe9\x51\x74\x9a\x3c\x00\x45\xc4\x02\x21\x1b\xa1\x32\x28\xba\x2d\xa8\xec\xdf\x6c\x16\x49\xa5\xd5\x0a\x16\x68\x74\x17\x46\x6d\x0b\x65\x53\x11\x31\xca\x33\x59\xb8\xe8\x18\x00\xec\x3c\x60\x23\xbb\x5e\x6b\xf0\xb9\x64\x79\x09\x36\x69\x64\x01\x24\x00\xdb\xee\x21\x0b\x6b\x10\x33\x1a\x98\x30\xa8\x0a\x92\x63\x88\x2e\x40\xd1\x88\x1c\x92\xb6\x85\x83\xec\x25\xe6\xc8\xae\x50\x79\xd5\x0e\x47\x0a\x1f\x78\x8d\xd3\xa8\x1d\x49\x1a\x03\x30\xa8\x07\xc3\x7d\x03\x50\xf8\x09\x0e\xb2\x33\xa6\x73\xc5\x2a\x26\x88\x91\xea\x29\x43\x4e\x07\xe3\x83\x13\x00\x0a\x4d\xa3\x44\x77\xb5\x62\xc2\x14\xb0\xff\xbf\x4f\xfb\xd3\xf3\xaf\x09\x6f\x26\x27\xc7\xd1\x1f\x93\x37\x36\x1b\x56\xab\xac\x6d\x73\x52\x61\x68\x5d\xa7\xd8\x54\xaa\xa0\xa1\xd0\xd5\x5e\xe8\xea\x4b\x34\x51\x6f\xeb\xbb\x79\xfb\x1e\x4e\xda\xa2\x41\x72\x45\xf8\x6e\x4f\xa5\x10\xf1\x95\xc0\x3b\xf8\xea\x2e\xa0\xc2\x31\x5c\x11\x7e\x13\xb4\xd1\xa5\xc8\xbf\x36\xfd\xce\xb0\x20\x0d\x37\x9b\xd5\x0a\x1e\x0c\x25\xe6\xdb\xef\xbe\x0f\x93\xa0\x47\x77\x37\xb6\xbd\xad\x29\xfc\x22\x2a\xa2\x6c\x83\xf9\xe9\xf2\xe2\x79\x32\x87\xb7\xef\xe6\x4b\x83\x29\xa0\x52\x52\x05\xf0\x6d\x6f\xa0\xae\xcb\x46\x97\x86\xd3\x57\x44\x81\xd9\x71\x7c\xd8\x68\x73\x49\x29\x78\x74\x0c\x1f\xb4\x14\xd9\xa0\x5d\xe2\xf4\x4a\xda\x36\xcc\x99\xc4\x6e\x1a\x60\x4a\x57\xab\xf4\x08\xfe\x6f\xd2\x1f\x3a\x19\xff\x39\x06\xc1\xf8\x28\x02\x7c\xa6\xa0\x52\x1b\x0e\xd9\x71\xf5\xfc\x1e\x42\x0f\x37\x3d\x71\x1c\xc7\x21\x31\xe9\xde\x44\xa4\x60\x7d\x34\x45\xa2\x64\x5a\x0d\xee\x33\xe1\xec\x45\x64\xb3\x02\x12\x3f\xaf\xbd\xb0\x99\x62\xd8\x95\x6b\xa7\x6e\x6c\xe9\x7a\x6e\xa3\x8d\xac\x9e\x4a\x55\x11\x63\x50\xb9\x11\x2e\xd1\x46\x31\xb1\x78\x2c\x85\x21\x4c\x68\xc8\x7e\x45\x25\x61\x3f\xf9\x6d\x7f\x3f\x4d\xd3\xe8\x6c\xe2\x27\xa1\xe9\x68\xb2\x45\xab\x6e\xba\x9b\x4f\x06\x1d\xdf\xcb\x4e\x38\xbf\x28\xc2\x36\xb6\xab\xc9\x6d\x6b\x73\x5f\xa8\xcf\xf9\x01\x62\xa3\xee\xfd\xdb\x9b\xbe\x96\xde\x74\x6f\x0f\xfd\x0d\x1b\x53\x64\x71\xfd\x61\xdb\xcc\x1c\x1d\xb1\x99\x08\xc6\xb7\xa1\x43\x6d\x74\xba\x00\xa5\x8a\xd4\x17\xea\x92\xb3\x1c\x7f\x44\x5b\x50\xb6\x95\x81\x0d\x60\x37\x2a\xc7\x84\x73\x0c\xd4\x53\xe4\xbc\xa1\xf8\x9a\x70\x46\x2d\xbe\x51\xd2\xd9\x7f\xeb\xb9\x47\xda\x1b\xee\xcb\x94\xa7\x81\x6b\xaa\x06\x54\x76\x03\xbc\xa5\x4d\x1d\x33\xea\x19\xd1\x98\xa1\x59\x0d\x5c\x85\x74\x8c\xe5\xd9\x30\xc3\x5a\x05\x8c\x42\x52\xa5\xa9\x5b\x7c\x89\x9f\x1a\x66\x29\x66\x76\x4e\xb4\xd7\x96\x49\x5b\x4c\xcf\xc9\x50\xaa\xe2\xb5\xd4\x01\x72\xd5\x5b\x38\x86\xd0\x53\xaf\x1b\x94\xb0\x07\x66\x33\xf0\xf7\x22\x78\x61\xd6\x66\x9b\x35\xb1\x94\xea\xf0\x71\x39\xd5\xdd\x0f\xcc\xb2\xb1\x0a\x85\x4f\x43\xd5\x08\xc3\x2a\xcc\xbc\x4c\x32\xe7\x18\xcc\xf0\xf3\xc6\x40\x49\x34\x08\xd9\xdf\xd5\x19\x6b\x24\xe4\x25\xe6\x1f\x1d\x8e\xdb\x06\x1b\x47\xa0\x9c\x35\x03\xe7\xdb\x60\x83\x5b\x48\xe0\x61\x48\x9e\x9c\x98\x64\xc2\xc5\x52\x08\x73\xd2\x53\x47\x18\xe7\xd9\x1d\x48\x5a\x3a\xe0\x9a\x14\x5d\xe3\xd4\xa0\x8d\x2a\x2a\x93\xbd\xc4\x05\xd3\x46\x2d\xc3\xd9\x2b\x18\x04\x26\x3d\xbf\x43\x3c\x20\x89\x40\x25\xea\xce\xb3\x03\xf4\x37\x23\xff\x08\x84\x94\x75\x84\xa8\xff\x99\xa0\x3d\x27\xda\x36\x7d\xbc\x36\x41\xc4\xee\x0a\xd2\xdc\xed\xfe\x12\xb1\x3a\xbe\xf8\x56\x21\xdb\x15\x27\x0a\x52\x80\xd7\x03\x98\x01\xa6\xa1\xb1\x5f\x6f\x1b\xcf\xe3\x7b\xff\xd1\x61\x3d\x71\x41\x92\x9b\xeb\x1e\xd9\x1e\xa6\x23\xf8\x8a\x43\x7e\xb3\x65\x64\x6f\x88\x30\xfa\x67\xc7\x02\x4e\x99\x20\x6a\x19\xe9\x40\x55\xb8\x7e\x53\x23\xf2\x0d\x22\xd2\xe9\xbc\x79\x9a\x2d\x04\x31\x8d\x42\x0b\x55\xbc\xaf\xda\x94\x5c\x2f\x3c\x33\x58\x69\x3b\x91\xda\x01\xdc\x06\xd3\xb4\xed\x78\xbf\x6f\x3e\x0e\x3a\x1b\xcf\xc9\xb6\x20\x0a\xba\x7f\xf7\xd2\x95\xed\xde\xe7\xc7\xe5\xf0\x0d\x8f\xca\xdc\x91\x81\xfe\xa9\x31\x5c\xf4\x8f\x3e\xcb\x75\xb1\x38\x93\xf9\x65\xb0\x3d\x18\x48\x62\x74\x29\x85\x8a\xd4\x6f\x9d\xfc\x77\x3b\x87\xad\x5b\x53\xee\xa9\x99\x0e\xdb\x41\xc0\x5f\x63\xdf\x36\xeb\xde\xde\xc2\xa8\x1d\x84\x70\x36\xbb\xc5\x54\xa6\x4b\xd9\x50\x98\xa3\x9f\xe3\xa8\x7b\xb6\xe6\xec\x23\x82\xc2\x45\xc3\x89\x0a\xde\xe6\x36\x86\x3f\x42\x29\x14\x0d\xe7\xa0\x9b\xda\x16\x95\xed\x21\x1b\x1b\x05\xad\x82\xc6\xd5\xd8\x4a\xda\xdc\x3d\xea\x92\x77\xfc\xe2\x67\x01\xb4\x45\xb9\x6e\x74\x89\x14\xa8\xfc\x2c\x6c\xfd\xb4\x1b\xd7\xc3\x7b\x3c\x89\xff\x08\x00\x00\xff\xff\x38\x2e\xed\x30\x73\x18\x00\x00")
+var _templatesSchemaGotmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x58\x5f\x6f\xdb\x38\x12\x7f\xcf\xa7\x98\xf3\xe5\x0a\x29\x48\xe5\xbb\x3e\xdd\xf5\x90\x87\xa4\x69\x9b\x1e\x70\x49\x51\xf7\x5a\xe0\xba\x45\x41\x8b\x23\x8b\xad\x44\x2a\x24\xe5\xc4\x2b\xf8\xbb\x2f\xf8\x47\x32\x25\xcb\x4e\xb2\xe9\x02\xc5\xee\xe6\xc9\x11\xc9\xe1\xcc\x6f\xfe\xfe\xd8\x34\x4f\x81\x65\x40\x38\x85\xe4\x8d\x3a\x23\x0a\xdf\xaf\x2a\x34\xbf\x5f\xde\x56\x42\x6a\xa4\x10\x71\xa1\xcd\x87\x59\x5d\xa1\x3c\x2d\x18\x51\x31\xac\xd7\x07\x00\xe6\xac\xc6\xb2\x2a\x88\x46\x98\xa8\x34\xc7\x92\xbc\x15\xc5\xaa\x14\xb2\xca\x59\x3a\x81\xc4\xec\x33\xbb\xb0\x50\x68\xae\xe9\x49\x71\x42\xb4\xb9\xae\x69\xa0\x22\x2a\x25\x05\xfb\x19\x21\xb9\x24\x25\xc2\x7a\x6d\xbe\x6e\xc4\x9b\x7d\x33\x7b\x85\x51\xd0\xc9\x6e\x9a\xe9\x11\xbc\x12\xd2\x0a\x51\x40\x31\x2d\x88\x44\x0a\x44\xc1\xa1\xc4\x0c\x04\x07\x25\x4a\x04\xa1\x73\x74\x9b\x8e\xe1\x6b\xad\x74\xbb\x13\x74\x8e\x4e\x01\xa2\x80\xc0\x42\x14\x84\x2f\xe0\x0b\x31\xda\x21\xfd\xe2\x4f\x60\xb2\x48\xdc\xae\x53\x38\x81\xb3\x04\x2e\x05\x94\xa8\x73\x41\x41\xe5\xa4\x28\x60\x8e\x20\xb1\xbd\x3c\x01\x38\x9a\x76\xf0\x38\x9b\x3b\x58\xed\x77\xe8\x1b\x36\xf7\x8b\x33\x94\xcc\x02\x20\x03\xe3\x3e\xe6\xc8\xad\x96\x56\xa7\xcd\x35\x46\xdd\x6a\x03\xb5\xd7\x94\x62\xc6\x38\x42\x46\x52\x2d\xe4\xca\x2b\xa9\xe0\x86\xe9\x1c\x74\xce\x94\x93\x92\x84\x0a\x22\xa7\x23\x4e\x7a\x59\xce\x91\x52\xa4\xbb\xfd\xdc\xee\x18\x3a\x39\xb4\x5c\x48\x23\xeb\x85\x28\xab\x02\x6f\xaf\xe6\x5f\x31\xb5\x71\xf4\xbe\xae\x0a\x1b\x61\xa7\x94\x32\xcd\x04\x27\xc5\x5b\x29\x2a\x94\x9a\xa1\x6a\x0d\x7f\x7f\x75\x7e\x15\x65\x12\x69\xfc\x1c\x72\xc2\x69\x81\x90\x12\x85\x20\x32\x50\xf5\xdc\x7a\x83\xf1\x1c\x25\xd3\x8c\x2f\x20\x93\xa2\x04\x03\xa4\xf3\x93\x35\x78\x4c\xfa\x31\x30\xa5\x6a\x84\xbf\x3e\x7b\xf6\xec\xef\x2d\x0c\xde\x23\xc6\x72\x1f\x79\x6d\x4c\xb2\x0c\x7c\xec\x77\xc9\x60\xd4\xeb\xf6\x35\x4d\x6b\xf4\x68\x00\x9b\x65\x4e\xc3\x1f\x7d\xcf\x3b\x24\xcf\x04\x5d\x79\x14\x9d\x26\x4f\x41\x12\xbe\x40\x48\x7a\xa8\x74\x8a\xee\x0a\x2a\xf3\x37\x9d\x8e\xa4\xd2\x7a\x0d\x0b\xd4\xca\x86\x51\xd3\x40\x5e\x97\x84\xf7\xf2\x4c\x64\x2e\x3a\x3a\x00\xad\x07\x4c\x64\x57\x1b\x0d\x6e\x72\x96\xe6\x60\x92\x46\x64\x40\x02\xb0\xcd\x1e\xb2\x30\x06\x31\xad\x80\x71\x8d\x32\x23\x29\x86\xe8\x02\x64\x35\x4f\x21\x6a\x1a\x38\x4c\xde\x61\x8a\x6c\x89\xd2\xab\x76\xd4\x53\xf8\xd0\x6b\x1c\x8f\xda\x11\xc5\x63\x00\x06\xf5\xa0\xbb\xaf\x03\x0a\xaf\xe1\x30\x39\x67\x2a\x95\xac\x64\x9c\x68\x21\x5f\x31\x2c\x68\x67\x7c\x70\x02\x40\xa2\xae\x25\xb7\x57\x4b\xc6\x75\x06\x93\xbf\x5d\x4f\x86\xe7\x3f\x90\xa2\x1e\x9c\xec\x47\xff\x98\xbc\xbe\xd9\xb0\x5e\x27\x4d\x93\x92\x12\x43\xeb\xac\x62\x43\xa9\x9c\x86\x42\xd7\x07\xa1\xab\x67\xa8\x47\xbd\xad\x1e\xe6\xed\x47\x38\x69\x87\x06\xd1\x92\x14\xfb\x3d\x15\xc3\x88\xaf\x38\x3e\xc0\x57\x0f\x01\x15\x4e\x60\x49\x8a\xbb\xa0\x1d\x5d\x1a\xf9\xd7\xa4\xdf\x39\x66\xa4\x2e\xf4\x76\xb5\x82\xa7\x5d\x89\xf9\xc7\x3f\xff\x15\x26\x41\x8b\xee\x7e\x6c\x5b\x5b\x63\xf8\x1f\x2f\x89\x34\x0d\xe6\x3f\xb3\xab\xcb\x68\x0e\x9f\x3e\xcf\x57\x1a\x63\x40\x29\x85\x0c\xe0\xdb\xdd\x40\x5d\x97\x1d\x5d\xea\x4e\x2f\x89\x04\xbd\xe7\x78\xb7\xd1\xe4\x92\x94\xf0\xfc\x04\xbe\x2a\xc1\x93\x4e\xbb\xc8\xe9\x15\x35\x4d\x98\x33\x91\xd9\xd4\xc1\x14\xaf\xd7\xf1\x31\x3c\xd1\xf1\xbf\xad\x8c\xbf\x9c\x00\x67\x45\x2f\x02\x7c\xa6\xa0\x94\x5b\x0e\xd9\x73\xf5\xfc\x11\x42\x8f\xb6\x3d\x71\x32\x8e\x43\xa4\xe3\x83\x81\x48\xce\xda\x68\x1a\x89\x92\x61\x35\x78\xcc\x84\x73\x30\x22\x9b\x65\x10\xf9\x79\xed\xad\xc9\x14\xcd\x96\xae\x9d\xba\xb1\xc5\xf6\xdc\x5a\x69\x51\xbe\x12\xb2\x24\x5a\xa3\x74\x23\x5c\xa4\xb4\x64\x7c\xf1\x42\x70\x4d\x18\x57\x90\xfc\x1f\xa5\x80\x49\xf4\xd3\x64\x12\xc7\xf1\xe8\x6c\xe2\x27\xa1\xe1\x68\xb2\x43\x2b\x3b\xdd\xcd\x07\x83\x8e\xef\x65\xa7\x45\x71\x95\x85\x6d\x6c\x5f\x93\xdb\xd5\xe6\xbe\x53\x9f\xf3\x03\xc4\x56\xdd\xfb\xb3\x37\xfd\x28\xbd\xe9\xd1\x1e\xfa\x1d\x36\xa6\x91\xc5\xcd\x87\x5d\x33\xf3\xe8\x88\xcd\x78\x30\xbe\x75\x1d\x6a\xab\xd3\x05\x28\x95\xa4\xba\x92\xb3\x82\xa5\xf8\x1a\x4d\x41\xd9\x55\x06\xb6\x80\xdd\xaa\x1c\x03\xce\xd1\x51\x4f\x9e\x16\x35\xc5\x0f\xa4\x60\xd4\xe0\x3b\x4a\x3a\xdb\x6f\x2d\xf7\x88\x5b\xc3\x7d\x99\xf2\x34\x70\x43\xd5\x80\x0a\x3b\xc0\x1b\xda\x64\x99\x51\xcb\x88\xfa\x0c\xcd\x68\xe0\x2a\xa4\x63\x2c\x6f\xba\x19\xd6\x28\xa0\x25\x92\x32\x8e\xdd\xe2\x3b\xbc\xae\x99\xa1\x98\xc9\x05\x51\x5e\x5b\x26\x4c\x31\xbd\x20\x5d\xa9\x8a\x07\xd3\x42\x84\xd7\x90\xcc\x6e\xc8\x62\x81\xd2\x96\xb2\x89\xab\xc4\x93\xce\x80\x97\xbc\x2e\x3b\xda\x96\x09\x09\xc8\xeb\x52\xd9\x5f\x6e\xee\xbe\x41\x58\x20\x47\x69\xa0\x4d\x05\x57\x1a\x22\xa2\xcb\x63\x10\xbc\x58\x81\x93\xa6\xe2\x1e\x9f\x71\xf5\xd3\x0a\x36\x95\xd3\x66\xd0\x25\xde\x8c\x77\xb8\xa5\xad\x1b\x86\xd9\xbc\x16\xbe\xd8\xc6\x36\xb7\x36\xff\xdb\xbc\x58\x9a\x26\x6c\x37\x1f\x74\x15\xe4\xc9\xf2\xe0\xbe\xb3\xd3\x56\x78\x2c\x5b\x7f\xf7\x03\xca\x13\xd1\x3b\x5c\x62\x0e\x4c\xa7\xe0\xbd\x80\xe0\x85\x99\x08\x30\x35\x64\xac\xc0\x58\xb0\x5d\x85\xb1\xf7\x03\x33\xdc\xb4\x44\xee\x8b\x92\xac\xb9\x66\x25\x26\x5e\x26\x99\x17\x18\x30\x9a\x79\xad\x21\x27\x0a\xb8\x68\xef\xb2\xae\xd7\x02\xd2\x1c\xd3\x6f\x2e\xaa\x76\x8d\x79\x8e\x4e\x3a\x6b\x3a\x06\xbc\xc5\x8d\x77\x50\xe2\xa3\x90\x4a\x3a\x31\xd1\x80\x99\xc6\x10\x56\x28\x4f\xa4\xa1\x5f\x75\x1e\x40\x59\xe3\x0e\xd7\x28\xb3\x63\x84\x32\x61\x96\x95\x3a\x79\x87\x0b\xa6\xb4\x5c\x85\x93\x68\x30\x16\x0d\x26\x20\x8b\x78\x40\x99\x81\x0a\x54\xd6\xb3\x1d\xf4\x77\x23\xff\x1c\xb8\x10\xd5\xc8\xb3\xc5\xaf\x49\xe1\x0b\xa2\xcc\x08\x84\xb7\x3a\xc8\xdf\xf1\xf1\xc7\x05\x49\xea\x76\x7f\x8f\x58\xed\x5f\x7c\xaf\x90\xb5\xa5\x9a\x82\xe0\xe0\xf5\x00\xa6\x81\x29\xa8\xcd\xd7\xfb\xc6\x73\xff\xde\x3f\x74\x58\x0f\x5c\x10\xa5\xfa\xb6\x45\xb6\x85\xe9\x18\x7e\xe0\x90\xdf\x6e\xa0\xc9\x47\xc2\xb5\xfa\xaf\xe3\x44\x67\x8c\x13\xb9\x1a\xe9\xc7\x65\xb8\x7e\x57\x5b\xf6\xed\x72\xa4\xef\x7b\xf3\x14\x5b\x70\xa2\x6b\x89\xb6\x47\x8d\xba\xd7\xa4\xe4\x66\xe1\x8d\xc6\x52\x99\xf9\xdc\xd0\x11\x13\x4c\xc3\x26\xec\xfd\xbe\xfd\x54\xea\x6c\xbc\x20\xbb\x82\x28\xe8\x3d\xf6\xdd\x2f\xd9\xbf\xcf\x93\x87\xf0\x45\x93\x8a\xd4\x37\x64\xff\xf0\x1a\x2e\xfa\x27\xb0\xd5\xa6\x58\x9c\x8b\x74\x16\x6c\x0f\xc6\xb3\xb1\xd6\x1a\x43\x49\xaa\x4f\x4e\xfe\xe7\xbd\xa3\xe7\xbd\x1f\x20\x86\x66\x3a\x6c\x3b\x01\xbf\x8d\x7d\xbb\xac\xfb\x74\x0f\xa3\xf6\xd0\xe3\xe9\xf4\x1e\x33\xaa\xca\x45\x4d\x61\x8e\x7e\xaa\xa5\xee\x11\xbf\x60\xdf\x10\x24\x2e\xea\x82\xc8\xe0\xa5\x72\x6b\x14\x26\x94\x42\x56\x17\x05\xa8\xba\x32\x45\x65\x77\xc8\x8e\x0d\xc6\x46\x41\xed\x6a\x6c\x29\x4c\xee\x1e\xdb\xe4\xed\xbf\x7f\x1a\x00\x4d\x51\xae\x6a\x95\x23\x05\x2a\x6e\xb8\xa9\x9f\x66\xe3\x86\xca\x8c\x27\xf1\x2f\x01\x00\x00\xff\xff\xba\x9a\x01\x98\x81\x19\x00\x00")
 
 func templatesSchemaGotmplBytes() ([]byte, error) {
 	return bindataRead(
@@ -368,8 +368,8 @@ func templatesSchemaGotmpl() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "templates/schema.gotmpl", size: 6259, mode: os.FileMode(0644), modTime: time.Unix(1482416923, 0)}
-	a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3a, 0xd6, 0xc6, 0x56, 0x8c, 0xce, 0x4f, 0x11, 0x45, 0xba, 0xcb, 0xb6, 0xc2, 0x28, 0xd4, 0x31, 0x52, 0x91, 0xbd, 0x36, 0xa7, 0xe5, 0xc4, 0x21, 0x15, 0xa1, 0xaa, 0x46, 0x3a, 0x8, 0x9f, 0x4f}}
+	info := bindataFileInfo{name: "templates/schema.gotmpl", size: 6529, mode: os.FileMode(0644), modTime: time.Unix(1482416923, 0)}
+	a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa4, 0x1b, 0x14, 0x27, 0x44, 0x98, 0x94, 0x30, 0x4f, 0x2b, 0x78, 0x30, 0x67, 0xe5, 0x68, 0xbb, 0x64, 0xaa, 0x72, 0x97, 0x2e, 0xbd, 0xdf, 0x47, 0x1e, 0xdd, 0x86, 0x5e, 0xa8, 0xff, 0x2b, 0x62}}
 	return a, nil
 }
 
diff --git a/generator/templates/schema.gotmpl b/generator/templates/schema.gotmpl
index 3422ec3f..bc00193f 100644
--- a/generator/templates/schema.gotmpl
+++ b/generator/templates/schema.gotmpl
@@ -78,6 +78,15 @@
 {{- end }}
 {{- if and .IncludeValidator (not .IsSuperAlias) (not .IsEmbedded) }}{{/* aliased types type A = B do not redefine methods */}}
   {{- if and (not (or .IsInterface .IsStream)) (or .Required .HasValidations .HasBaseType) }}
+    {{- if (eq .SwaggerType "string") }}{{/* Enum factory for enums for which we generate const (atm, only strings)*/}}
+      {{- if .Enum }}
+
+func New{{ pascalize .Name }}(value {{ .GoType }}) *{{ .GoType }} {
+  v := value
+  return &v
+}
+      {{- end }}
+    {{- end }}
     {{ template "schemavalidator" . }}
   {{- else if not (or .IsInterface .IsStream) }}
 // Validate validates this {{ humanize .Name }}{{/* this schema implements the runtime.Validatable interface but has no validations to check */}}


Test patch:
diff --git a/generator/model_test.go b/generator/model_test.go
index dae147f9..a0d0ee3f 100644
--- a/generator/model_test.go
+++ b/generator/model_test.go
@@ -2669,3 +2669,27 @@ func TestGenerateModels(t *testing.T) {
 		}
 	})
 }
+
+func Test_Issue2482(t *testing.T) {
+	// generation of a pointer converter for enum vars
+	specDoc, err := loads.Spec("../fixtures/bugs/252/swagger.json")
+	require.NoError(t, err)
+
+	definitions := specDoc.Spec().Definitions
+	k := "SodaBrand"
+	opts := opts()
+	genModel, err := makeGenDefinition(k, "models", definitions[k], specDoc, opts)
+	require.NoError(t, err)
+	require.False(t, genModel.IsNullable)
+
+	buf := bytes.NewBuffer(nil)
+	require.NoError(t, opts.templates.MustGet("model").Execute(buf, genModel))
+
+	ct, err := opts.LanguageOpts.FormatContent("soda_brand.go", buf.Bytes())
+	require.NoError(t, err)
+
+	res := string(ct)
+	assertInCode(t, "func NewSodaBrand(value SodaBrand) *SodaBrand {", res)
+	assertInCode(t, "v := value", res)
+	assertInCode(t, "return &v", res)
+}