scottlogic / openapi-forge-csharp Goto Github PK
View Code? Open in Web Editor NEW๐ OpenAPI Forge generator for C#
๐ OpenAPI Forge generator for C#
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.
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.
see:
This relies on a Windows environment.
this logic needs flipping round ...
https://github.com/ScottLogic/openapi-forge-csharp/blob/master/template/Configuration.cs.handlebars#L19-L26
need to build the URL from BasePath then Server
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.
see: https://github.com/ScottLogic/openapi-forge-csharp/search?q=%22the+response+should+be+of+type%22
I think this is a cut/paste mistake, it looks like quite a bit of this code is redundant.
This results in error CS8618
The TypeScript client includes a working example based on the Swagger Petstore:
https://github.com/ScottLogic/openapi-forge-typescript/tree/main/example
It would be great to make this our standard example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.