小编Web*_*per的帖子

如何在OpenAPI(Swagger)中为相同的HTTP状态代码定义不同的响应?

我正在为现有的API编写OpenAPI规范.此API为成功和失败返回状态200,但具有不同的响应结构.

例如,在注册API中,如果用户成功注册,则API会使用以下JSON发送状态200:

{
    "result": true,
    "token": RANDOM_STRING
}
Run Code Online (Sandbox Code Playgroud)

如果有重复的用户,API也会发送状态200,但使用以下JSON:

{
    "result": false,
    "errorCode": "00002", // this code is duplicated error
    "errorMsg": "duplicated account already exist"
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,如何定义响应?

swagger openapi

6
推荐指数
1
解决办法
6307
查看次数

Prisma部署Docker错误“无法连接到服务器”

这是我已经完成的步骤

prisma init
Run Code Online (Sandbox Code Playgroud)

我在本地设置数据库的PostgreSQL(不存在)。

它创建了3个文件,分别是datamodel.graphql,docker-compose.yml,prisma.yml

docker-compose up -d
Run Code Online (Sandbox Code Playgroud)

我确认它成功运行 在此处输入图片说明 但是如果我打电话给我prisma deploy,那说明我出错了

Could not connect to server at http://localhost:4466. Please check if your server is running.
Run Code Online (Sandbox Code Playgroud)

我所做的只是手册中描述的标准操作,https://www.prisma.io/docs/tutorials/deploy-prisma-servers/local-(docker)-meemaesh3k中没有自定义

这是docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.11
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: localhost
            port: '5432'
            database: databasename
            schema: public
            user: postgres
            password: …
Run Code Online (Sandbox Code Playgroud)

docker graphql prisma

6
推荐指数
2
解决办法
2860
查看次数

在 Go 中将文件放入 amazon s3 后如何获取文件 url?

文件上传成功,上传后我想返回文件url。

_, err := s3.New(s).PutObject(&s3.PutObjectInput{
    Bucket:               aws.String("bucket"),
    Key:                  aws.String(tempFileName),
    ACL:                  aws.String("public-read"), // could be private if you want it to be access by only authorized users
    Body:                 bytes.NewReader(buffer),
    ContentLength:        aws.Int64(int64(size)),
    ContentType:          aws.String(http.DetectContentType(buffer)),
    ContentDisposition:   aws.String("attachment"),
    ServerSideEncryption: aws.String("AES256"),
    StorageClass:         aws.String("INTELLIGENT_TIERING"),
})
Run Code Online (Sandbox Code Playgroud)

我已经检查了亚马逊文档中的 PutObject 函数,但是 PutObjectOutput 结构类型 但此结构中没有上传的文件 url。

我怎样才能获取文件的url?上传成功后是否有其他方法在 amazon s3 sdk 中返回上传的文件 url?

file-upload amazon-s3 go

6
推荐指数
1
解决办法
5226
查看次数

如何在firebase API中使用confirmPasswordReset(code, newPassword)?

我将使用 2 个 firebase API 来实现忘记密码功能。

1 sendPasswordResetEmail
2 confirmPasswordReset
Run Code Online (Sandbox Code Playgroud)

当我调用 sendPasswordResetEmail 时,Firebase Api 将密码重置网址发送到我的电子邮件,但现在我必须获取验证码作为确认密码重置的参数。我想知道confirmPasswordReset函数中的“代码”来自哪里。(我在电子邮件中看不到代码,Firebase API 仅发送密码重置网址)

firebase firebase-authentication

5
推荐指数
1
解决办法
4897
查看次数

如何查看已激活插件中未使用的插件?

我有一个 WordPress 网站,并且激活的插件太多。所以我想知道我可以停用哪些插件。有没有相关的插件或者我应该一一检查?

wordpress

5
推荐指数
1
解决办法
4657
查看次数

使用ng2-ckeditor时,'CKEditor 4.x缺少(http://ckeditor.com/)'警告,角度为4

我将为我的angular 4项目使用ng2-ckeditor插件.我读了指南,有systemjs文件的配置.但我在我的角度4 cli项目中找不到systemjs.所以除了systemjs config之外,我做了指南中提到的其他事情.最后的结果是简单的文本框和警告

'CKEditor 4.x is missing (http://ckeditor.com/)'
Run Code Online (Sandbox Code Playgroud)

这些都是我所做的.

1)    /*added this script to my component html file*/
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
2) 
npm install ng2-ckeditor
3) set appmodule
import { CKEditorModule } from 'ng2-ckeditor';

@NgModule({
  // ... 
  imports:      [
    CKEditorModule
  ],
  // ... 
})
export class AppModule { }

4) use component
      <ckeditor [(ngModel)]="content" debounce="500">
      <p>Hello <strong>world</strong></p>
      </ckeditor>
Run Code Online (Sandbox Code Playgroud)

我想知道如何设置systemjs,即使我在我的项目中找不到systemjs文件而且无论如何都没有设置这个?最好的祝福

components angular

5
推荐指数
1
解决办法
4799
查看次数

测试运行完成后,Jest 一秒钟都没有退出。--检测打开句柄

我将测试使用 Jest 运行的后端服务器。有时会成功,但有时会显示这样的错误。 在此输入图像描述

因此,如果我按照建议使用 --detectOpenHandles 标志,它总是成功而不显示任何错误。这是测试代码。

  it("should be able to initialize a server (development)",async (done) => {
      // Before main() is called there is no active connection:

    expect(connection.readyState).toBe(0);
    return main({
      env: "dev",
      port: PORT,
    })
    .then(async (server: ApolloServer) => {
        // After main() got called, there is an active connection:
      expect(connection.readyState).toBe(1);
      await server.stop();
      done();
    })
  });
  afterAll(async () => {
    await connection.close(); //connection is mongoose.connection
  });
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它在标记时失败。奇怪的是,有时成功,有时失败。

谢谢

apollo jestjs graphql apollo-server

5
推荐指数
1
解决办法
1051
查看次数

为什么要为 wp_enqueue_scripts 插入 wp_head()?

我已将此代码添加到 functions.php 但 startwordpress_scripts() 函数没有运行。

function startwordpress_scripts() {
    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.6' );
    wp_enqueue_style( 'blog', get_template_directory_uri() . '/css/blog.css' );
    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.3.6', true );
}

add_action( 'wp_enqueue_scripts', 'startwordpress_scripts' );
Run Code Online (Sandbox Code Playgroud)

所以我在 header.php 中添加了以下代码,它们运行良好。

<?php wp_head(); ?>
Run Code Online (Sandbox Code Playgroud)

现在我想知道 wp_head() 函数的神奇作用。谢谢。

javascript css wordpress

3
推荐指数
1
解决办法
2897
查看次数

如何仅为提供的键更新猫鼬文档的嵌套对象

我将根据提供的密钥更新猫鼬文档的某些字段。例如,当我们在json中显示猫鼬文档时。

user: {
  address: {
    city: "city"
    country: "country"
  }
}
Run Code Online (Sandbox Code Playgroud)

并且更新参数是这样给出的。

address: {
   city: "city_new"
}
Run Code Online (Sandbox Code Playgroud)

当我像这样运行猫鼬API时。

let params = {
   address: {
      city: "city_new"
   }
}
User.set(param)
Run Code Online (Sandbox Code Playgroud)

替换整个地址对象,最终结果是

user: {
  address: {
    city: "city_new"
  }
}
Run Code Online (Sandbox Code Playgroud)

它只是替换地址字段,但我只想更新城市字段。这是期望的结果。

user: {
  address: {
    city: "city_new"
    country: "country"
  }
}
Run Code Online (Sandbox Code Playgroud)

用猫鼬怎么做?

当嵌套对象的层次结构更复杂时,如何在不手动指示字段的情况下解决该问题 address.city.field1.field2. ...

谢谢

nested mongoose mongodb node.js

3
推荐指数
2
解决办法
556
查看次数

aws s3 存储桶中的文件在通过 aws cli 同步后不公开

你好吗。我正在使用 aws s3 存储桶同步 react.js Web 应用程序构建目录。当我通过输入亚马逊控制台(https://s3.console.aws.amazon.com/)手动将构建目录中的文件上传到 s3 时,所有上传的文件都是公开的,因此当我访问端点时,它显示网站很好(我正在使用s3 用于静态网站托管)

但是如果我将它与 aws cli 同步

aws s3 sync build/ s3://mybucketnamehere --delete
Run Code Online (Sandbox Code Playgroud)

我可以在存储桶中看到所有上传的新文件,但这些都被拒绝访问,所以当我进入网站时它给了我 403 错误。

这是政策

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:DeleteObject",
                "s3:DeleteObjectTagging",
                "s3:DeleteObjectVersion",
                "s3:DeleteObjectVersionTagging",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::mybucketnamehere",
                "arn:aws:s3:::mybucketnamehere/*"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

谢谢

amazon-s3 amazon-web-services reactjs aws-cli

3
推荐指数
1
解决办法
752
查看次数