-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[csharp] Add a server generator for FastEndpoints #19690
[csharp] Add a server generator for FastEndpoints #19690
Conversation
Just noticed an error in record generation. When a parameter is optional it should be put in the body and not in the primary constructor. |
thanks for the PR please take your time fixing the bug. let us know if you need help. |
@@ -0,0 +1,14 @@ | |||
generatorName: aspnet-fastendpoints | |||
outputDir: samples/server/petstore/aspnet/fastendpoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding the new folder to github workflow (e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-dotnet8-server.yaml) so that CI will test it moving forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I also added configuration file for each option available in the generator
I have only one point I don't know how to solve a point. Here is the edited template :
My problem is : how to avoid to insert a "," in the constructor if a parameter is the last parameter that is #required or if there is not #required parameter at all. |
what about using {{^-last}} ... {{/-last}}? there are 2 more parameter lists for required and optional parameters:
would these help? |
There is also a join with comma lambda. |
a39a880
to
fb5d45b
Compare
Perfect. Done. |
Not sure how to fix this error on action execution : https://github.com/OpenAPITools/openapi-generator/actions/runs/11091036118/job/30820196576#logs
To get the project built the line
These GUID are created by the generator. I could give them a default value and let the user to choose if he want to generate new values |
any convention in naming the FastEndpoint class? In other server generators, we usually add "Api" as the suffix to avoid name collision with model names. |
The convention are to add a "Request" suffix for the requests, which is what I have done. The "Response" suffix is used for the responses. That is what I have done too, but I revert it back. The reason is that when using the generator a model can also be used as the body of a request. And a request containing a property of type "SomethingResponse" didn't make any sense. Maybe I could generate two models, one with a suffix "Response" and an other with, maybe, "Body" suffix. The drawback, I think, is that some classes could not be used at all. |
While checking again the required parameter and testing with a "real" open-api yaml file I noticed that some required parameters are not genereated as required. I don't know if I made a mistake or miss something but looks like that parameter that are of form type are not included in the required parameters. Here is a part of the yaml :
|
I have tried, adding a suffix will do. if I do something like : |
@@ -152,3 +152,5 @@ org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen | |||
org.openapitools.codegen.languages.WsdlSchemaCodegen | |||
org.openapitools.codegen.languages.XojoClientCodegen | |||
org.openapitools.codegen.languages.ZapierClientCodegen | |||
|
|||
org.openapitools.codegen.languages.AspnetFastendpointsServerCodegen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this line based on alphabetical order
for model, i wouldn't recommend using a suffix by default for endpoints, looks like adding a suffix like "Request" to avoid the naming collision with models if I understand it correctly. |
No, in this case, the collision is because both FastEndpoints and the generated project provide a type with the same name: Generated requests and endpoints already have a suffix. |
ok. thanks for the details 2 ways to handle this kinda siutation:
|
Use a fully qualified name. We ought to be using fully qualified names everywhere, but we don't for some reason. |
I used a fully qualified name. Hope everything works now. |
https://github.com/OpenAPITools/openapi-generator/actions/runs/11312510702/job/31462379731?pr=19690 please update the samples when you've time |
pull_request: | ||
paths: | ||
- samples/server/petstore/aspnetcore-8.0/** | ||
- samples/server/petstore/aspnetcore-8.0-*/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will need to update the above 4 lines (path) referencing fastendpoints path mentioned below in order to trigger the CI to run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Generator that support the basics of a FastEndpoints project https://fast-endpoints.com/
94cf966
to
8bcd948
Compare
Not sure how to solve that. Even after having updated the sample I still have |
This Guid need to be constant, it is related to project type
@wing328 Solved. It was an issue with my dev environment. OK after clearing the IDE cache. |
@wing328 Is there something more I need to correct on this PR ? |
https://github.com/OpenAPITools/openapi-generator/actions/runs/11392557217/job/32653087692?pr=19690 i'll fix it after merging this PR UPDATE: done via 28e02fc |
This pull request add a new generator for FastEndpoints.
It allows to generate an ASP.NET server project that use FastEnpoints.
Options allows to enable some FastEndpoints functionalities like :
Related issue : #19649
Technical committee mentions
@mandrean @shibayan @Blackclaws @lucamazzanti @iBicha