This is first naive version of Giraffe server generator from OpenAPI specification
I believe in "contract-first" approach, and your OpenAPI spec is basically contract for your API
Backend code is just an implementation of this contract and client doesn't really want to know about it
Neither should you, so this library will help you with that
It follows Myriad approach and defines MSBuild target to generate code based on input
It's still in VERY early stage of development, so only VERY basic features are being supported.
- Creating models from OpenAPI schemas
- records generated from schema definitions with all data types from spec
- handlers in generated webApp should support these types
-
oneOfsupport -
anyOfsupport -
allOfsupport -
discriminatorsupport -
notwon't be supported
- Multiple responses from one endpoint
- Creating endpoints with path/query/body bindings
- Add XML comments on top of endpoint from OpenAPI descriptions
- Support authentication (best efforts)
- Support JSON/XML (de-)serialization
- Add nuget
GiraffeGenerator.Sdk - Create OpenAPI spec file
- Add generated file to your project file:
<Compile Include="Generated.fs">
<OpenApiSpecFile>spec.yaml</OpenApiSpecFile>
</Compile>
- Build project to generate the file
- Implement interface defined in this file and register your implementation in AspNetCore DI
- It parses OpenAPI spec with package
Microsoft.OpenApi.Readersto intermediate representation (IR) - Then it creates F# AST based on that IR
- Finally it produces source code file with help of
Fantomas
- Restore tools:
dotnet tool restore dotnet pwsh build.ps1
At this stage there is no NuGet package publishing and packages are being published locally
To consume them in Example project there is local NuGet.Config with local repo added
After first full build&pack you could delete Generated.fs file from Example project and build it again to see that it actually generates on build
