首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >添加新的应用程序服务时Swagger崩溃

添加新的应用程序服务时Swagger崩溃
EN

Stack Overflow用户
提问于 2018-10-10 00:38:42
回答 1查看 1K关注 0票数 1

在你阅读this post之前,要知道我已经看过这篇文章了……问题几乎是一样的,我已经尝试过这个解决方案。所以这篇文章不是重复的。

我们使用了ASP.NET样板启动模板。我们已经开发了一些应用程序服务,它们的结构如下:

代码语言:javascript
复制
public interface IFooAppService : 
    IAsyncCrudAppService<FooDto, Guid, GetAllFooDto, CreateFooDto, UpdateFooDto>
    // Abp.Application.Services.IAsyncCrudAppService<...>
{
}

[AbpAuthorize("Authorize.Foo")]
public class FooAppService : 
    AsyncCrudAppService<Foo, FooDto, Guid, FooFilterInput, CreateFooDto, FooDto>,
    IFooAppService
{
    private readonly BarManager _barManager;
    public FooAppService(IBarManager barManager, IRepository<Foo, Guid> repository)
        : base (repository)
    {
        _barManager = barManager;
    }

    public override async Task<FooDto> Create(CreateFooDto input)
    {
        // create with repository
    }

    // other overridden Actions and Foo interface implementation
}

所有内容都与可用的here文档一致。

所有的方法都工作得很好,我可以使用Swagger的所有功能。配置似乎还可以(我们为ABP注入了一些后JavaScript,...)等等。

最初,我有以下版本:

  • Microsoft.AspNetCore:2.0.1
  • Microsoft.EntityFrameworkCore:2.0.1
  • Abp.AspNetCore:3.6.2
  • Swashbuckle.AspNetCore:1.1.0

我们有385 API。

我添加了一个新的AppService、承诺,以及它的经理、Dtos等。

这时,当我启动并大摇大摆时,我的浏览器崩溃了,并显示一条消息,询问我是否要停止脚本(IE,Edge,Firefox,Chrome,...)。

在调试模式下,我没有关于可能抛出的异常的信息。

已尝试:

  1. Update Swashbuckle.AspNetCore NuGet软件包(所有版本: 1.2、2.X和3.0.0)

代码语言:javascript
复制
- In version 1.X, I've the same problem.
- In version 2.5, UI doesn't displayed.
- In other versions, UI is displayed, I can use all methods EXCEPT my new methods, Commitment. When I click hover him, I've only the spinner... Browser freezes and ask me if I want to stop the script or wait. 

在Chrome上,Chrome引发错误:

  1. Remove覆盖了用于承诺的方法

以防我的代码在被覆盖的方法中出错。

代码语言:javascript
复制
[AbpAuthorize("Authorize.Commitments")]
public class CommitmentAppService : 
    AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput, CreateCommitmentDto, UpdateCommitmentDto>,
    ICommitmentAppService
{
    private readonly ICommitmentManager _commitmentManager;
    private readonly IFundManager _fooManager;
    private readonly ILimitedPartnerManager _barManager;

    public CommitmentAppService(
        ICommitmentManager commitmentManager,
        IFooManager fooManager,
        IBarManager barManager,
        IOneRepository<Commitment, Guid> repository)
        : base(repository)
    {
        _commitmentManager = commitmentManager;
        _fooManager = fooManager;
        _barManager = barManager;
        _commitmentManager = commitmentManager;
    }
    // nothing here
}

同样的结果。

  1. Use一个DTO (CommitmentDto),而不是一组DTO CommitmentDto,CreateCommitmentDto,UpdateCommitmentDto,...

代码语言:javascript
复制
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid>` where are defined the Entity, its DTO and PK type
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput>` where are defined the Entity, its default DTO, PK type, and Filter Input DTO
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput, CommitmentDto>` where are defined the Entity, its default DTO, PK type, Filter Input DTO and Creation Entity DTO
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput, CommitmentDto, CommitmentDto>` where are defined the Entity, its default DTO, PK type, Filter Input DTO, Creation Entity DTO and Update Entity DTO

同样的结果。

  1. Use other AsyncCrudAppService implementations

代码语言:javascript
复制
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid>`where are defined the Entity, its DTO and PK type
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput>`  where are defined the Entity, its default DTO, PK type, and Filter Input DTO
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput, CreateCommitmentDto>` where are defined the Entity, its default DTO, PK type, Filter Input DTO and Creation Entity DTO
- `AsyncCrudAppService<Commitment, CommitmentDto, Guid, CommitmentFilterInput, CreateCommitmentDto, UpdateCommitmentDto>` where are defined the Entity, its default DTO, PK type, Filter Input DTO, Creation Entity DTO and Update Entity DTO

同样的结果。

validate的

  1. Use编辑器

Swagger (OpenApi,我知道...)在https://editor.swagger.io/提供了一个在线编辑器

我复制了swagger.json并将其粘贴到编辑器中。我有一些关于语义的错误(我认为这是由于从Json到Yaml的转换造成的)。

paths./api/services/app/Foo/GetAll.get.responses.200.schema.$ref RFC3986值处的

语义错误必须是符合百分比编码的URI跳到第234行

无法解决paths./api/services/app/Foo/GetAll.get.security.0.0安全作用域定义Funds.BankAccounts处的语义错误跳至第240行

对于CommitmentAppService,我没有特殊的错误。我可以展开除承诺方法之外的所有项目...浏览器崩溃,诸如此类

  1. Rename对Toto
  2. Remove的承诺几个方法管理来验证Swagger
  3. Import 的API数量不是太多在Azure swagger.json管理中我可以扩展所有方法,甚至是承诺方法...但是我不知道如何使用我的数据库(这不是我的目标,我希望调试locally).
  4. Clean构造函数……也许我注入的项目中有一个是错误的?

代码语言:javascript
复制
public CommitmentAppService(IRepository<Commitment, Guid> repository) 
: base(repository)
{ /**/ }

不..。

如果有人有解决方案..。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52725643

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档