Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Description #19017

Open
famattsson opened this issue Jun 25, 2024 · 0 comments
Open

[BUG] Description #19017

famattsson opened this issue Jun 25, 2024 · 0 comments

Comments

@famattsson
Copy link

famattsson commented Jun 25, 2024

It seems like there is some strange behaviour when generating input from generic types. I have this model for input

    public class RoomsFilter
    {
        public InType<List<Guid>>? RoomIds { get; set; } = null;
        public InType<List<Guid>>? BuildingIds { get; set; } = null;
        public ContainsType<string>? PopularName { get; set; } = null;
        /// <summary>list of properties to sort results </summary>
        public RoomSortKey? SortKey { get; set; } = null;
        /// <summary>Order to sort results by.</summary>
        public SortOrder? SortOrder { get; set; } = null;
    }

While the ContainsType and InType look like this

    public class FilterTypes
    {
        public class EqualsType<T>
        {
            public required T Eq { get; set; }
        }

        public class InType<T>
        {
            /// <summary>Include everything that is contained in the list.</summary>
            public required T In { get; set; }
        }
      
        public class ContainsType<T>
        {
            /// <summary>Include everything that is contained in the string.</summary>
            //Why is this even generic? This logic would probably only make sense for strings anyway
            public required T Contains { get; set; }
        }
    }

The generated code looks like this:

        /// <summary>
        /// Find rooms based on filter. Find rooms based on filtering options.
        /// </summary>
        /// <exception cref="RealEstateCoreApi.ClientSDK.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="roomIdsIn">Include everything that is contained in the list. (optional)</param>
        /// <param name="buildingIdsIn">Include everything that is contained in the list. (optional)</param>
        /// <param name="popularNameContains">Include everything that is contained in the list. (optional)</param>
        /// <param name="sortKey">list of properties to sort results (optional)</param>
        /// <param name="sortOrder">Order to sort results by. (optional)</param>
        /// <param name="page"> (optional)</param>
        /// <param name="perPage"> (optional)</param>
        /// <param name="operationIndex">Index associated with the operation.</param>
        /// <returns>RoomDtoRecApiPaginationResult</returns>
        public RoomDtoRecApiPaginationResult GetRooms(List<Guid>? roomIdsIn = default(List<Guid>?), List<Guid>? buildingIdsIn = default(List<Guid>?), string? popularNameContains = default(string?), RoomSortKey? sortKey = default(RoomSortKey?), SortOrder? sortOrder = default(SortOrder?), int? page = default(int?), int? perPage = default(int?), int operationIndex = 0)
        {
            RealEstateCoreApi.ClientSDK.Client.ApiResponse<RoomDtoRecApiPaginationResult> localVarResponse = GetRoomsWithHttpInfo(roomIdsIn, buildingIdsIn, popularNameContains, sortKey, sortOrder, page, perPage);
            return localVarResponse.Data;
        }

As you can tell, the argumets that are marked as nullable in the source code are not marked as such in the resulting generated code. This behaviour appeared after we upgraded our project to .net 8 and upgraded the generator version to 7.6.0. But reverting the generator version does not fix the issue, so it seems like it might be related to .net 8.

This is how the generated code looked before the .net 8 upgrade and the version bump:

       /// <summary>
        /// Find rooms based on filter. Find rooms based on filtering options.
        /// </summary>
        /// <exception cref="RealEstateCoreApi.ClientSDK.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="roomIdsIn">Include everything that is contained in the list. (optional)</param>
        /// <param name="buildingIdsIn">Include everything that is contained in the list. (optional)</param>
        /// <param name="popularNameContains">Include everything that is contained in the list. (optional)</param>
        /// <param name="sortKey">list of properties to sort results (optional)</param>
        /// <param name="sortOrder">Order to sort results by. (optional)</param>
        /// <param name="page"> (optional)</param>
        /// <param name="perPage"> (optional)</param>
        /// <param name="operationIndex">Index associated with the operation.</param>
        /// <returns>RoomDtoRecApiPaginationResult</returns>
        public RoomDtoRecApiPaginationResult GetRooms(List<Guid>? roomIdsIn = default(List<Guid>?), List<Guid>? buildingIdsIn = default(List<Guid>?), string? popularNameContains = default(string?), RoomSortKey? sortKey = default(RoomSortKey?), SortOrder? sortOrder = default(SortOrder?), int? page = default(int?), int? perPage = default(int?), int operationIndex = 0)
        {
            RealEstateCoreApi.ClientSDK.Client.ApiResponse<RoomDtoRecApiPaginationResult> localVarResponse = GetRoomsWithHttpInfo(roomIdsIn, buildingIdsIn, popularNameContains, sortKey, sortOrder, page, perPage);
            return localVarResponse.Data;
        }

We have not changed any settings or anything else aside from the version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant