question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

x-ms-enum: we should revise enum deserialization to exclude a need of breaking change in case of a new value

See original GitHub issue

This sounds like a good and immutable candidate for enum:

        "dayOfWeek": {
          "type": "string",
          "description": "Day of the week when a cache can be patched.",
          "enum": [
            "Monday",
            "Tuesday",
            "Wednesday",
            "Thursday",
            "Friday",
            "Saturday",
            "Sunday",
          ],
          "x-ms-enum": {
            "name": "DayOfWeek",
            "modelAsString": false
          }
        },

but owner team decided to introduce 2 more values: “Everyday” and “Weekend”. And it will be a breaking change in the generated SDK (at least in C# and Java) with unnecessary major version bump of the package. We need to have better handling of enum enhancements in our generated code to avoid this kind of “silly” version breaks in client libraries (Server API devs does not consider it as a breaking change and they will not change an API version for a new enum value).

For example we can introduce “Unknown” value as the first/default one in the generated enums and have a special handling/intermediate step in the deserialization component that will set Server returned values to Unknown if they are not in the current set of enum values.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ro-joowancommented, Sep 12, 2017

Folks from the Azure Data Lake team would also love to have this feature. Our current Swagger design was to set the enums with modelAsString: false. Therefore, moving to modelAsString: true now causes a couple of major issues: (1) The breaking change of moving enum type to string type for the customer and (2) The current modelAsString: true model creates a static class of the enum type, which prevents instantiation.

1reaction
brjohnstmsftcommented, Nov 12, 2016

Unknown is a lot less usable than getting a strongly-typed object that you can identify by looking at its underlying string value. That’s why we implemented ExtensibleEnum in the first place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How can I ignore unknown enum values during json ...
Here is one I put together using a few pieces from the StringEnumConverter class that comes from Json.Net. It should give you the...
Read more >
Breaking Changes | HackerNoon
All of it has one consequence — we need to change data representations. ... During deserialization, unrecognized enum values will be ...
Read more >
AIP-180: Backwards compatibility - API Improvement Proposals
Therefore, it is important to understand what constitutes a backwards compatible change and what constitutes a backwards incompatible change.
Read more >
Change in handling of enum when moving from 2.6 to 2.7
When I serialize an object containing the enum value BoxTypeEventPart.INSTANCEBOX using Jackson 2.6.7 the string will contain" "INSTANCEBOX". When I change ...
Read more >
Deserializing to an enum - no dogma blog
I have an application where I deserialize an xml stream from a third ... code which can be one of only three values,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found