Git Product home page Git Product logo

openapi-forge-csharp's People

Watchers

 avatar  avatar  avatar  avatar

openapi-forge-csharp's Issues

Use DateOnly in C# generator for date type

In ScottLogic/openapi-forge#185, it is established that swagger distinguishes date and date-time types. The necessary changes to address this has been made in the main repo (see ScottLogic/openapi-forge#187).

To reflect these changes, C# tests are also altered in #50. However, these changes are applied on a surface level where both date and date-time strings are still represented by DateTime type in C#. In the mentioned PR, the tests conditionally convert the testing property into DateOnly on runtime in an ad-hoc way.

For context, C# introduced DateOnly type [1] in dotnet6. However, they haven't introduced the serialisation/deserialisation for this type until dotnet7 [2]. Since the test project is on dotnet6 (which is a LTS release), it is not possible to use the DateOnly type on generated code.

To address the mentioned problem, one option is to write custom ser/deser methods which can be undesirable for generated code structures. A more viable second option to bring the project to dotnet >=7 at a later stage to eliminate this limitation. The testing of date/datetime can be streamlined from that point onwards.

Injected

The API client classes take a Configuration instance in their constructor, which is provided by the DI framework. However, in order to provide configuration, the Startup.RegisterApiClient function takes a user-supplied config instance:

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OpenApiForge;

var services = new ServiceCollection();
services.Add(new ServiceDescriptor(typeof(Configuration), typeof(Configuration), ServiceLifetime.Scoped));

// this config object is not the same as the one injected via the DI framework
var config = new Configuration() {
  BasePath = "https://petstore3.swagger.io",
};

Startup.RegisterApiClient(services, config);

As a result, the user-supplied values are not respected by the API client classes.

Fix CSharp testing for Ubuntu

The CSharp testing works on a windows and macOS machines but not on Ubuntu machines.

Tested using GitHub Actions runners:
ubuntu-latest : does not work
windows-latest : works
macos-latest : works

Requirements: developer to own a machine running Ubuntu.

This doesn't field like it is high priority, the reasoning is to allow all GitHub Actions to run on all the same runners.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.