-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use new Microsoft.Extensions.ApiDescription.Server package #2226
Conversation
<description>$description$</description> | ||
<tags>Swagger Documentation WebApi AspNet TypeScript CodeGen</tags> | ||
<projectUrl>https://github.com/NSwag/NSwag</projectUrl> | ||
<licenseUrl>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</licenseUrl> |
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.
@RicoSuter does it matter (much) that I'm using old GitHub locations for this repo i.e. should projectUrl
be https://github.com/RicoSuter/NSwag ?
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.
We should use the correct URL, why using the old one?
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.
This matches what I see in your released packages. I'll update.
@RicoSuter please let me know if this needs to change at all. FYI our 3.0 Preview 6 release should be soon. |
@dougbu does this have to be part of the v13.0.0 release? We can push this later, right? This all is WiP anyway, correct? |
@RicoSuter this will only be WIP for a few more days (I think) and I'd really like to see it in your next release. |
@dougbu is it ok to do a patch release (v13.0.1) with this in a few days? I really want to get this version out :-) |
Sure❕ I wasn't directing, just asking 😺 |
Do we really need to use a nuspec file? I dont like this as it’s quite bit harder to maintain deps etc.. |
@RicoSuter it's not possible to add a dev dependency to a shipped package without the .nuspec file. W.r.t. maintaining dependencies, I tried to minimize the issues by keeping all of the versions in the .csproj file. |
Does this mean that the spec is generated on build by default when the NSwag.AspNetCore package is installed.
Does this also work when multiple IDocumentProviders are registered, e.g. also from Swashbuckle or another document generator like GRPC or AsyncApi?
Isn't this a breaking change, e.g. for "older" target frameworks? |
Yes, it's on by default.
Can be disabled using
Not really. The |
3.0 Preview 6 packages are now public. This PR can be safely merged, perhaps with a release note mentioning |
If I only install nswag.aspnetcore, will it still auto gen the specs even if they are not used anywhere? Or what is this feature for? |
Yes, it will get the documents and save them in obj/ by default. The feature is for both API compatibility checks (when default doc location is overridden and user chooses to check the files in) and consumption in client projects using |
1cf2396
to
73dcaef
Compare
🆙📅 to rebase on 'master' and change all GitHub URLs to avoid the extra redirects |
I don't like this as it means that I still pay the performance impact even if I'm only interested in the HTTP middlewares (specs + web UI) and do not store the documents in the filesystem or use any
Compatibility checks = doing a diff in the PR? |
That's not viable because Users concerned about performance or just don't want the docs can use
Yes |
For me it feels user-violent that when you install a package like NSwag.AspNetCore the build immediately takes much longer (I have big APIs which take > 20s) and you are not even using a feature of it. I think 80% of the users only want the Swagger UI + spec server (only generated on demand when accessing /swagger) and will not use spec generation to file or service project references... With this you immediately get the penalty (because no user will know of this new option) and the feature is not even usable... Wouldnt it be better if we create a new package, e.g. NSwag.AspNetCore.Build (or whatever?) which has this enabled etc. and which references the original NSwag.AspNetCore package? |
The idea is to enable the document generation by default exactly so that code generation works end-to-end. There’s no way to know if there’s another project depending on this one until `OpenApiGetDocuments` is invoked.
* the feature is not even usable
What do you mean? With the changes in this PR, everything works end-to-end.
From: Rico Suter <notifications@github.com>
Sent: June 13, 2019 12:28
To: RicoSuter/NSwag <NSwag@noreply.github.com>
Cc: Doug Bunting (AAPT) <Douglas.R.Bunting@microsoft.com>; Mention <mention@noreply.github.com>
Subject: Re: [RicoSuter/NSwag] Use new Microsoft.Extensions.ApiDescription.Server package (#2226)
... and feels user-violent.
For me it feels user-violent that when you install a package like NSwag.AspNetCore the build immediately takes much longer (I have big APIs which take > 20s) and you are not even using a feature of it. I think 80% of the users only want the Swagger UI + spec server (only generated on demand when accessing /swagger) and will not use spec generation to file or service project references... With this you immediately get the penalty (because no user will know of this new option) and the feature is not even usable...
Wouldnt it be better if we create a new package, e.g. NSwag.AspNetCore.Build (or whatever?) which has this enabled etc. and which references the original NSwag.AspNetCore package?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FRicoSuter%2FNSwag%2Fpull%2F2226%3Femail_source%3Dnotifications%26email_token%3DABRCFPOGA46T55ZXDIVM2VLP2KNVRA5CNFSM4HWZMRNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXUZE2I%23issuecomment-501846633&data=02%7C01%7CDouglas.R.Bunting%40microsoft.com%7C5c93f4afc6134615747f08d6f0354e0e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636960509071693159&sdata=07tkRMAFfycREFfP6FwAVDhzgIOtJf0c4mFjNHFK6G0%3D&reserved=0>, or mute the thread<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABRCFPJO4WKL4I5ETY7S723P2KNVRANCNFSM4HWZMRNA&data=02%7C01%7CDouglas.R.Bunting%40microsoft.com%7C5c93f4afc6134615747f08d6f0354e0e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636960509071693159&sdata=Pog5NhT0ew3jQhvY17IRsNshm37XZn5aIY%2FSkKIBWYY%3D&reserved=0>.
|
NSwag.AspNetCore will then depend on a preview package, isn't this a problem? |
No more than NSwag.ApiDescription.Client depending on a preview package -- just leads to another warning in your build that can be ignored. In any case, the feature is code compete at this point though it has a couple of rough edges we'll fix in 3.0 preview 7. @glennc and I'll discuss moving from 0.3.0 to 3.0.0 for these packages in preview 7 (which might be closer to release candidate). |
I just want to ensure that this does not break existing users - not everyone is using the latest versions of .NET Core 3... |
No, it won't break existing users, especially because we're switching the feature to be opt-in as you requested. Will update this PR to that end soon. |
This all is preview at the moment anyway - so enabling it by default should be discussed later I think... |
I’ve changed the versions to v13.0.2 and as soon as you updated the pr i’ll merge and release it. |
Thanks @RicoSuter! I've been laid up since yesterday and might not get to this 'til early next week. |
73dcaef
to
7151494
Compare
🆙📅 to rebase on 'master' (removing conflicts) and change doc generation to opt-in |
This pr might interfere with #2261 |
@RicoSuter yes it will conflict. If you and @mkArtakMSFT like, I could add |
We can absolutely simplify this by including the flag in this PR. |
@RicoSuter I added the property setting to this PR. I'll remove this last commit if you prefer to separate the concerns. |
- provides document download on build and aligns with Microsoft.Extensions.ApiDescription.Client p2p references - this feature is off by default (though Microsoft.Extensions.ApiDescription.Server features are normally opt-out) - can be enabled using `<OpenApiRetrieveDocuments>true</OpenApiRetrieveDocuments>` - changes to `$(OpenApiDocumentsDirectory)` also enable the feature - timing can be changed using `<OpenApiRetrieveDocumentsAfterBuild>false</OpenApiRetrieveDocumentsAfterBuild>` - then, depend on the `RetrieveOpenApiDocuments` target from somewhere else - add `GetDocumentNames()` to `IDocumentProvider` and `AspNetCoreOpenApiDocumentGenerator` - rename `IDocumentProvider` namespace Microsoft.Extensions.ApiDescription -> Microsoft.Extensions.ApiDescriptions - avoid conflict with `Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescription` type - depend on Microsoft.Extensions.ApiDescription.Server package from NSwag.AspNetCore package - restore and update the previously-unused (then deleted) NSwag.AspNetCore.nuspec file nits: - remove and sort `using`s - update remaining 13.0.0 version - take VS suggestions in `NSwagServiceCollectionExtensions` - add missing `NSwagServiceCollectionExtensions` copyright header - correct spelling in `AspNetCoreOpenApiDocumentGenerator`
- https://github.com/NSwag and https://github.com/RSuter just add an extra hop to https://github.com/RicoSuter
016ecbf
to
b147cad
Compare
🆙📅 again to split concerns more clearly into 3 commits |
@dougbu Can you point me to the docs with the available msbuild tags, e.g. OpenApiRetrieveDocuments or OpenApiDocumentsDirectory - is there a ways to also specify the file name, e.g. rename it to openapi.json? |
Document filenames are intentionally not controllable. They following the format Of course, this is all MSBuild. Users could for example leave the documents in More generally, what is the main impetus for changing the document filenames (especially for files that land in Documentation is currently minimal. Most of the information is in Microsoft.Extensions.ApiDescription.Server.props. |
So there's no easy way to generate an openapi.json for a given document name (e.g. "v1") in the web project dir? |
In a target that runs after <Copy SourceFiles="$(OpenApiDocumentsDirectory)/$(MSBuildProjectName).json"
DestinationFiles="$(MSBuildProjectDirectory)openapi.json" /> |
<OpenApiRetrieveDocuments>false</OpenApiRetrieveDocuments>
<OpenApiRetrieveDocumentsAfterBuild>false</OpenApiRetrieveDocumentsAfterBuild>
RetrieveOpenApiDocuments
target from somewhere elseGetDocumentNames()
toIDocumentProvider
andAspNetCoreOpenApiDocumentGenerator
IDocumentProvider
namespace Microsoft.Extensions.ApiDescription -> Microsoft.Extensions.ApiDescriptionsMicrosoft.AspNetCore.Mvc.ApiExplorer.ApiDescription
typenits:
using
sNSwagServiceCollectionExtensions
NSwagServiceCollectionExtensions
copyright headerAspNetCoreOpenApiDocumentGenerator