简体   繁体   中英

openapi-generator how to generate a c-sharp .NET core 3.1 compatible test in my solution's MS Test project?

I have a .net-core 3.1 solution with a simple endpoint accepting only a post. I want to use openAPI-generator to generate the SDK (because the New REST Client SDK option is not available in visual studio for mac ).

The first time I did this, I did it with the command:

openapi-generator generate -i ../swagger.v0.0.21.json -g csharp -o ./generator

this generated a .net framework solution, so I had to hack it a bit and install some nuget test libraries to get it to run at all. I was getting connection refused after all that -- which I hope is just related to the fact that it was built for the wrong framework.

I'm noticing there is another generate target, csharp-netcore . I'm not sure how to use it though. What should my command look like? I was thinking:

openapi-generator generate -i ../swagger.v0.0.21.json -g csharp-netcore -targetFramework netcoreapp3.1 -o ./generator

but that yields:

[error] Found unexpected parameters: [netcoreapp3.1]

(just to be explicit, I have a solution structure:

  • Assignment_1/
    • Assignment_1_Tests/

and it is in that that I would like to do my testing. but my source is directly off of the Assignment_1 directory.

Try using --additional-properties=targetFramework=netcoreapp3.1

Source: https://openapi-generator.tech/docs/usage/#additional-properties

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM