Skip to content
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

How does this work? #9

Open
justoke opened this issue Sep 4, 2020 · 1 comment
Open

How does this work? #9

justoke opened this issue Sep 4, 2020 · 1 comment

Comments

@justoke
Copy link

justoke commented Sep 4, 2020

I have installed this extension and managed to create a config file, but after that it is a mystery as to how this is actually supposed to work. How exactly do you generate the API from the JSON file? Is there a CLI of some sort?

The only thing that I see is a flickering blue cursor next to the GENERATOR FROM SWAGGER:

image

Thank you.

@jkcapoeira
Copy link

These are my notes how i used it today. Wanted to create the server app, in case i don't have internet connection.
I am a newbie on this, so just consider this as my 2 cents.

Creating server app:

Install .net core hosting 3.1
Install the Generator From Swagger tool.
Create and select a workfolder
Click on the extension in the sidebar.
At the top of the extension: Create config
Edit config.
Swagger path is the file of the swagger json. If it is a yaml file, you can convert it online to a json.
the path is relative to the work folder. So normally just the filename.
change the language if needed to

  • "c#", for the client.
  • "aspnetcore" for the server

refresh the generator
you have now an

  • exampleClient
  • exampleServer

right mouse button on the exampleServer -> Generate will create the application

Now run the start.bat from the terminal in vscode
after it has build the project, you can start the server with
'dotnet run --project src\Org.OpenAPITools\Org.OpenAPITools.csproj' (use --project and don't use the launchprofile)
the server is now running with the kestral webserver under http://localhost:8080/openapi/index.html

[
    {
        "name": "exampleClient",
        "generator": "openapi-toolkit",
        "type": "client",
        "language": "c#",
        "swaggerPath": "Pre Paid API Swagger Oct 20.json",
        "outputFolder": "./generatedClientFromSwagger",
        "options": {
            "namepsace": "OpenapiDefinitionGenerate",
            "modelsFolderName": "models",
            "modelNamePrefix": "",
            "modelNameSuffix": "",
            "controllersFolderName": "controllers",
            "controllerNamePrefix": "",
            "controllerNameSuffix": "Controller"
        }
    },
    {
        "name": "exampleServer",
        "generator": "http://api.openapi-generator.tech/api/gen",
        "type": "server",
        "language": "aspnetcore",
        "swaggerPath": "Pre Paid API Swagger Oct 20.json",
        "options": {
            "supportsES6": true,
            "apiPackage": "api",
            "modelPackage": "models",
            "withSeparateModelsAndApi": true
        },
        "outputFolder": "./generatedServerFromSwagger"
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants