Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Problem with enums in discriminator #450

@caldras

Description

@caldras

Good morning,

I have a little problem with enums and I have not found a solution yet. I have a RAML like the next piece:

types:
customControlAttributes:
type: object
discriminator: kind
properties:
kind:
required: true
type: string
enum: [CUSTOMER_ACCESS_CONTROL, CONTRACT_ACCESS_CONTROL, USER_CHANNEL_CONTROL, CONTRACT_CHANNEL_CONTROL, AMOUNT_CHANNEL_CONTROL, AUDITABLE_DATA, MASK_AND_UNMASK, ENCRYPTION_AND_DECRYPTION]

This generates correctly a Java classs which has an attribute of type KindType which is an enum. The problem arises when I try to inherit that class:

customer:
type: customControlAttributes.customControlAttributes
discriminatorValue: CUSTOMER_ACCESS_CONTROL
description: |
Annotation to verify that it's an attribute that identifies the client.

That RAML generates the Customer class but the discriminator value is not an enum value but an string:

public interface Customer extends CustomControlAttributes {
String _DISCRIMINATOR_TYPE_NAME = "CUSTOMER_ACCESS_CONTROL";
}

public class CustomerImpl implements Customer {
@JsonProperty("kind")
private final Customer.KindType kind = _DISCRIMINATOR_TYPE_NAME;
}

I don't know if there is a way to cast that to the corresponding enum value.

There is also another problem with enums inside parent classes. Those enums are redefined when inheriting from those classes. This can be solved putting those enums outside those classes but I only tell you to warn you about the problem.

Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions