Repository: cjbooms/fabrikt (kotlin)

Issue:
Polymorphic generation creates empty JsonSubtypes
If your schema casing isn't consistent with the class name casing, the JsonSubtypes value of polymorphic discriminator objects is empty.

e.g., given this (where only the case of `polymorphicEnumDiscriminator` is modified from the example in the project:

```yaml
openapi: 3.0.0
paths: {}
info:
  title: ""
  version: ""
components:
  schemas:
    Wrapper:
      type: object
      properties:
        polymorph:
          $ref: '#/components/schemas/polymorphicEnumDiscriminator'
    polymorphicEnumDiscriminator:
      type: object
      discriminator:
        propertyName: some_enum
        mapping:
          obj_one_only: '#/components/schemas/ConcreteImplOne'
          obj_two_first: '#/components/schemas/ConcreteImplTwo'
          obj_two_second: '#/components/schemas/ConcreteImplTwo'
          obj_three: '#/components/schemas/ConcreteImplThree'
      properties:
        some_enum:
          $ref: '#/components/schemas/EnumDiscriminator'

    ConcreteImplOne:
      allOf:
        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'
        - type: object
          properties:
            some_prop:
              type: string

    ConcreteImplTwo:
      allOf:
        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'
        - type: object
          properties:
            some_prop:
              type: string
              
    ConcreteImplThree:
      allOf:
        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'

    EnumDiscriminator:
      type: string
      enum:
        - obj_one_only
        - obj_two_first
        - obj_two_second
        - obj_three
```

you get:

```kotlin
@JsonTypeInfo(
  use = JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.EXISTING_PROPERTY,
  property = "some_enum",
  visible = true
)
@JsonSubTypes()
sealed class PolymorphicEnumDiscriminator() {
  abstract val someEnum: EnumDiscriminator
}
```

It doesn't seem like the case of anything else matters, just the discriminator object.

Pull request:
Fix casing issue in polymorphic Json Subtype resolution.
Closes #144

Patch:
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
index 16f3a054..1e61afb7 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
@@ -342,7 +342,7 @@ class JacksonModelGenerator(
         val subTypes = allSchemas
             .filter { model ->
                 model.schema.allOfSchemas.any { allOfRef ->
-                    allOfRef.name == modelName && allOfRef.discriminator == discriminator
+                    allOfRef.name?.toModelClassName() == modelName && allOfRef.discriminator == discriminator
                 }
             }
         val mappings = subTypes.flatMap { schemaInfo ->


Test patch:
diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml b/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml
index 13caccc1..0759213d 100644
--- a/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml
+++ b/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml
@@ -9,8 +9,8 @@ components:
       type: object
       properties:
         polymorph:
-          $ref: '#/components/schemas/PolymorphicEnumDiscriminator'
-    PolymorphicEnumDiscriminator:
+          $ref: '#/components/schemas/polymorphicEnumDiscriminator'
+    polymorphicEnumDiscriminator:
       type: object
       discriminator:
         propertyName: some_enum
@@ -25,7 +25,7 @@ components:
 
     ConcreteImplOne:
       allOf:
-        - $ref: '#/components/schemas/PolymorphicEnumDiscriminator'
+        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'
         - type: object
           properties:
             some_prop:
@@ -33,7 +33,7 @@ components:
 
     ConcreteImplTwo:
       allOf:
-        - $ref: '#/components/schemas/PolymorphicEnumDiscriminator'
+        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'
         - type: object
           properties:
             some_prop:
@@ -41,7 +41,7 @@ components:
               
     ConcreteImplThree:
       allOf:
-        - $ref: '#/components/schemas/PolymorphicEnumDiscriminator'
+        - $ref: '#/components/schemas/polymorphicEnumDiscriminator'
 
     EnumDiscriminator:
       type: string