dotnet tool install --global dotnet-sdlexport --version 0.0.24
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local dotnet-sdlexport --version 0.0.24
nuke :add-package dotnet-sdlexport --version 0.0.24
<a href="https://www.buymeacoffee.com/sungam3r" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
.NET Core Global Tool for generating SDL from url or executable file.
You can install the latest version via NuGet.
> dotnet tool install -g dotnet-sdlexport
Command Line Options
to see all available options. See CommandLineOptions for more information.
What is it ?
This tool generates a text SDL (Schema Definition Language) file from the given URL or path to the
executable ASP.NET Core assembly. In the case of using URL, the tool immediately sends introspection
request to that URL. If the path to the file is specified as the source, then the tool starts the
temporary process and stops it after receiving the introspection response. The tool will be able
to send requests only when it starts the process on the URL it knows. This parameter is passed
--url command line switch and has default value
parameter is then passed as the
--server.urls command line switch to the process being launched.
It should be noted that with this method, the service should not (although it may) perform any side work
at startup, such as contacting external systems, databases, etc. as this may slow down the process of
obtaining the schema. The tool passes
API_ONLY_RESTRICTED_ENVIRONMENT command line key to the
process being launched. By the presence of this key, it is possible to disable the execution of code
that is not required to obtain a schema:
public static Task Main(string args) => CreateBuilder(args) .Build() .RunAsync(); private static IWebHostBuilder CreateBuilder(string args) => args.Contains("API_ONLY_RESTRICTED_ENVIRONMENT") ? WebHost.CreateDefaultBuilder<StartupApiOnly>(args) : WebHost.CreateDefaultBuilder<Startup>(args);
Why do I need it ?
SDL is easier to work with than with raw JSON introspection response. SDL is easier to read and understand. SDL is also much more compact in comparison with raw JSON - in this case it's easier to track changes. SDL file, like any code file, can be stored as an artifact in the version control system and act as a service public API.
The tool can get information about directives if the server supports this feature. If the server does not support directive return (in this case server returns a request validation error), then the tool uses the classic introspection request. The official specification does not describe such a possibility, although discussions are underway to expand the specification to add this feature.
sdlexport --source https://api.github.com/graphql --auth bearer|<YOUR_TOKEN> --out samples/github.graphql
sdlexport --source https://swapi-graphql.netlify.com/.netlify/functions/index --out samples/swapi.graphql
- HIVDB - A curated database to represent, store and analyze HIV drug resistance data. [Generated SDL]
sdlexport --source https://hivdb.stanford.edu/graphql --out samples/hivdb.graphql
- Countries - Information about countries, continents, and languages, based on Countries List. [Generated SDL]
sdlexport --source https://countries.trevorblades.com --out samples/countries.graphql
- You can export the schema directly from your published ASP.NET Core app
> sdlexport --source C:\MyWebHost.dll --out samples/myschema.graphql
To see the full list of available options:
|Product||Versions Compatible and additional computed target framework versions.|
|.NET||net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed.|
|.NET Core||netcoreapp3.1 is compatible.|
This package has no dependencies.