Skip to content

Commit

Permalink
[csharp] Add a server generator for FastEndpoints (#19690)
Browse files Browse the repository at this point in the history
* Add of a first working generator for FastEndpoints framework

Generator that support the basics of a FastEndpoints project
https://fast-endpoints.com/

* Add respose code documentation support

* Add an option to enable use of problem details

* Clean enum and model

* Add an option to generate record for requests/models

* Update sample

* Add support of nullable types

* Add option to enable authentication

* Add option to generate validators

* Clean readme.md file

* Add option to enable response caching

* update readme template

* Add missing files references

* Update generated sample

* Add link to documentation

* Add generator documentation

* correctly support packageName

supportingFiles additions moved to processOpts()

* improve useAuthentication option handling

Avoid to copy an empty file

* processOpts, move call to parent at the end

* Update generated sample

* Refactor and fix super.processOpts(); call order

* Handle the case of multi-line description

* Rename field to match naming conventions

* Add useApiVersioning option

* Update generated sample

* Add generator documentation

* Fix record when model contains optional properties

* Add configuration files for each option

* Add sample project for each configuration

* Add GitHub Action workflow for sample projects

* Add FastEndpoints BindFrom attribute on path, query and form params

* Update sample generated projects

* Fix validator template

* fix alphabetical order

* Use fully qualified name for FastEndpoints

* Add options to set GUID to be used in sln file

* update sample projects

* Update generators.md

* Fix path in github workflow

* Put readme, gitignore and solution file at the root of generated project

* update sample projects

* Remove the projectGuid option

This Guid need to be constant, it is related to project type

* update sample projects
  • Loading branch information
elendil-software authored Nov 7, 2024
1 parent e2553a4 commit 7deecdc
Show file tree
Hide file tree
Showing 196 changed files with 14,406 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/samples-aspnet-fastenpoints-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Samples C# .Net 8 FastEndpoints Server

on:
push:
paths:
- samples/server/petstore/aspnet/fastendpoints/**
- samples/server/petstore/aspnet/fastendpoints-*/**
pull_request:
paths:
- samples/server/petstore/aspnet/fastendpoints/**
- samples/server/petstore/aspnet/fastendpoints-*/**
jobs:
build:
name: Build .Net 8 FastEndpoints servers
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- samples/server/petstore/aspnet/fastendpoints
- samples/server/petstore/aspnet/fastendpoints-useApiVersioning
- samples/server/petstore/aspnet/fastendpoints-useAuthentication
- samples/server/petstore/aspnet/fastendpoints-useProblemDetails
- samples/server/petstore/aspnet/fastendpoints-useRecords
- samples/server/petstore/aspnet/fastendpoints-useResponseCaching
- samples/server/petstore/aspnet/fastendpoints-useValidators
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
dotnet-version: '8.0.x'
- name: Build
working-directory: ${{ matrix.sample }}
run: dotnet build Org.OpenAPITools.sln
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useApiVersioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useApiVersioning
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "false"
useAuthentication: "false"
useValidators: "false"
useResponseCaching: "false"
useApiVersioning: "true"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{1EC59EB0-DA5B-40C0-8E49-A3E0829DBBFC}"
projectConfigurationGuid: "{9685C490-9B77-4EE2-BE4D-811F52665E8F}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useAuthentication.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useAuthentication
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "false"
useAuthentication: "true"
useValidators: "false"
useResponseCaching: "false"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{10D45F9B-F270-480C-9DA9-720AA62526A4}"
projectConfigurationGuid: "{3FA19D58-AE7C-45E5-B00E-7482026D1816}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useProblemDetails.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useProblemDetails
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "true"
useRecords: "false"
useAuthentication: "false"
useValidators: "false"
useResponseCaching: "false"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{EA9B735E-72CA-44C4-BB28-358BDECE60C8}"
projectConfigurationGuid: "{74D68BAC-36F5-43FC-BE9A-F3E660EECF5D}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useRecords.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useRecords
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "true"
useAuthentication: "false"
useValidators: "false"
useResponseCaching: "false"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{C5D2BEB0-AB74-433F-BC14-DA66CAC82C10}"
projectConfigurationGuid: "{D465FD3B-3146-4661-BB50-522608AA3967}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useResponseCaching.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useResponseCaching
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "false"
useAuthentication: "false"
useValidators: "false"
useResponseCaching: "true"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{BC56C2A3-ACC5-4ED0-AD8F-CD1831B8A467}"
projectConfigurationGuid: "{5D19ACAB-8830-47FD-BAFA-C0985DF9F5F3}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints-useValidators.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints-useValidators
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "false"
useAuthentication: "false"
useValidators: "true"
useResponseCaching: "false"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{C7818EE1-09E2-4349-9696-8B1A9119974A}"
projectConfigurationGuid: "{39B801D8-74AA-465D-A637-4A2FFB905378}"
16 changes: 16 additions & 0 deletions bin/configs/aspnet-fastendpoints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatorName: aspnet-fastendpoints
outputDir: samples/server/petstore/aspnet/fastendpoints
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/aspnet-fastendpoints
additionalProperties:
hideGenerationTimestamp: "true"
useProblemDetails: "false"
useRecords: "false"
useAuthentication: "false"
useValidators: "false"
useResponseCaching: "false"
useApiVersioning: "false"
routePrefix: "api"
versionPrefix: "v"
solutionGuid: "{4BC03566-F5F9-4E45-A835-8FA3B2B524B9}"
projectConfigurationGuid: "{5F32A09C-5CB7-4917-83AB-CD7D1A04FF49}"
1 change: 1 addition & 0 deletions docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The following generators are available:

## SERVER generators
* [ada-server](generators/ada-server.md)
* [aspnet-fastendpoints](generators/aspnet-fastendpoints.md)
* [aspnetcore](generators/aspnetcore.md)
* [cpp-pistache-server](generators/cpp-pistache-server.md)
* [cpp-qt-qhttpengine-server](generators/cpp-qt-qhttpengine-server.md)
Expand Down
Loading

0 comments on commit 7deecdc

Please sign in to comment.