-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add Microsoft.Extensions.ApiDesription.Server project and package #10669
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
Conversation
dougbu
commented
May 30, 2019
- Add Web Application project support for build-time OpenAPI document generation #8242 2 of 2
Also addresses #4912 because I didn't restore the |
@natemcmaster I'd of course appreciate any input you have on the MSBuild changes |
.../Extensions.ApiDescription.Server/src/build/Microsoft.Extensions.ApiDescription.Server.props
Show resolved
Hide resolved
src/Mvc/Extensions.ApiDescription.Server/src/Microsoft.Extensions.ApiDescription.Server.nuspec
Show resolved
Hide resolved
.../Extensions.ApiDescription.Server/src/build/Microsoft.Extensions.ApiDescription.Server.props
Outdated
Show resolved
Hide resolved
096bb75
to
1c0d301
Compare
Bit more overlap with #10667 but resolution won't be too difficult |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
<NoPackageAnalysis>true</NoPackageAnalysis> | ||
|
||
<!-- Included primarily to ensure dotnet-getdocument and GetDocument.Insider can be referenced. --> | ||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks> |
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.
Have you tested this tool when only a .NET Core 3.0 SDK is installed? I didn't see anything which configures rollforward, so I would expect the dotnet get-document.dll
command to fail with a "Could not find .NET Core 2.1..." error.
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.
See #10667. That adds runtimeconfig.template.json
files for dotnet-getdocument
and GetDocument.Insider
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.
Oh, I also confirmed this works fine in a 3.0-only environment with 3.0 projects
Options added to the Open API retrieval tool ('dotnet-getdocument') command line. Available options control | ||
console output: 'no-color', 'prefix-output' and 'verbose'. All require a double-dash prefix. | ||
--> | ||
<OpenApiGetDocumentOptions Condition=" '$(OpenApiGetDocumentOptions)' == '' "></OpenApiGetDocumentOptions> |
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 line doesn't do anything. "If OpenApiGetDocumentOptions is empty, assign OpenApiGetDocumentOptions to empty."
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.
Good catch! This property should be true
by default
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.
Oh, wait. This is here only for documentation purposes. Should be empty by default.
<!-- | ||
If 'true' (the default), enable retrieval of Open API documents. Otherwise, this feature is completely disabled. | ||
--> | ||
<OpenApiRetrieveDocuments Condition=" '$(OpenApiRetrieveDocuments)' == '' ">true</OpenApiRetrieveDocuments> |
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.
Why would I install this package and then disable it's functionality completely? Seems like it would be simpler to say "if you want to disable the feature, uninstall the package"
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.
Users are not usually aware of this package at all. We'll be working with NSwag and SwashBuckle to ship with a dependency on it in their existing NSwag.AspNetCore and SwashBuckle.AspNetCore. Those packages have a lot of features and some users may wish to disable this particular one.
That is, we decided on opt-out for saving Open API docs after build.
@natemcmaster @JunTaoLuo builds are looking much better now 😺 |
</ItemGroup> | ||
|
||
<Target Name="OpenApiGetDocuments" Returns="@(_OpenApiProjectDocuments)"> | ||
<ReadLinesFromFile File="$(_OpenApiDocumentsCache)"> |
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.
Is this actually a cache? or is this just the output of generating the documents?
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.
TL;DR
Is your question aimed at my naming (and life) choices? I don't see much consistency in how similar MSBuild properties are named and chose something that fit.
Make a suggestion if you feel strongly please.
Details
This file is many things…
It's a cache in the sense seen in lots of MSBuild code: It's a way to avoid redoing an action (calling a task, executing a too, whatever). In particular, this file avoids reopening the app whenever a client project calls OpenApiGetDocuments
.
Yes, as an implementation detail, this file is one of the files written as a result of running the tool. It lists the document files.
The file is also like many used in MSBuild code in that it summarizes multiple inputs or outputs of a task or tool. For example, I could do the Inputs=$(TargetPath)
… Outputs=$(_OpenApiDocumentsCache)
batching trick to avoid running dotnet-getdocument
even if there are multiple document files.
Finally, this file is the communication mechanism between the GenerateOpenApiDocuments
and OpenApiGetDocuments
targets.
|
||
<Message Importance="high" Text="%0ARetrieveOpenApiDocuments:" /> | ||
<Message Importance="high" Text=" $(_Command)" /> | ||
<Exec Command="$(_Command)" /> |
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 are the caching expectations of this? Should we be adding some things to FileWrites
so they can be removed by incremental clean?
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.
I have been thinking about FileWrites
both here and in the client-side glue. But, every time I start making those changes, I hit the "What if the user plans to check these files in?" question. These files aren't always throw-away. But, I could probably complicate things enough to avoid that concern e.g. with conditions on $(OpenApiDocumentsDirectory)
matching the default.
I'll add a note to #4923 reminding me to work through the implications and do something.
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.
Discussed in person. Right now there is no input/output checking and this command will re-run every time you build, even if the assembly does not change.
This is tracked separately and will be improved in the next preview.
- remove incorrect `$(IsImplementationProject)` settings and re-run .\eng\scripts\GenerateProjectList.ps1 - address PR comments - correct extra word in a comment that @JunTaoLuo noticed nits: - minor formatting changes in Microsoft.Extensions.ApiDescription.Server.props - remove the project file's extension from the file list cache filename
- rename targets and the project capability for consistency - left the `OpenApiGetDocuments` target alone because it's used from client projects and isn't about generation
…osoft.Extesions.ApiDescription.Client.targets nits: - more s/retrieve/generate/
57d669c
to
2de02fa
Compare
🆙📅 for smaller fixes and a rebase on 'master'. Could someone please approve? |
Retargeted to preview 6 branch. PR validation begun again. /cc @mkArtakMSFT |
Just another Helix hang unrelated to anything in this PR. Merging… |
This comment was made automatically. If there is a problem contact [email protected]. I've triaged the above build. I've created/commented on the following issue(s) |