read-write-api-specs icon indicating copy to clipboard operation
read-write-api-specs copied to clipboard

x-namespaced-enum not generating correctly when using Swagger-CodeGen

Open nimble-software opened this issue 5 years ago • 2 comments

Hi,

Problem:

When using swagger-codegen to generate server or client code using the open banking specs, the use of the x-namespaced-enum property as opposed to just enum is causing the code to generate incorrectly.

Description

When using the enum property the code generator correctly creates the enum and references the enum in the appropriate class i.e. in OBAccount3 the accountType and accountSubType fields correctly reference the generated enums, i.e.

  @JsonProperty("AccountType")
  private OBExternalAccountType1Code accountType = null;

  @JsonProperty("AccountSubType")
  private OBExternalAccountSubType1Code accountSubType = null;

However when the x-namespaced-enum property is used the class that references that property simply has it's field defined as a String. An example of this can be seen in the OBBranchAndFinancialInstitutionIdentification5 class, where the schemeName property is a String as opposed to an actual enum i.e.

@JsonProperty("SchemeName")
private String schemeName = null;

Question

Has a vendor extension been created that will allow the code generator to correctly create and reference the appropriate enum class, as opposed to just defining a String?

nimble-software avatar Mar 03 '20 07:03 nimble-software

Have you had a look at https://github.com/swagger-api/swagger-codegen/issues/9020? It looks very similar (I know it says Swift4 in the title).

mbana avatar Mar 04 '20 09:03 mbana

@nimble-software Properties tagged with format - x-namespaced-enum are not Statically Typed enum. The data type of the field is String, to allow API Provider to extend upon it without breaking the client implementations. In earlier release, the enums were listed in examples attribute of OpenAPI Schema, which essentially they are. Functionally such types in OB UK ecosystem are called Namespaced Enumerations.

nitin-tiwari avatar Mar 16 '20 10:03 nitin-tiwari