我正在为现有的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)
在这种情况下,如何定义响应?
这是我已经完成的步骤
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) 文件上传成功,上传后我想返回文件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?
我将使用 2 个 firebase API 来实现忘记密码功能。
1 sendPasswordResetEmail
2 confirmPasswordReset
Run Code Online (Sandbox Code Playgroud)
当我调用 sendPasswordResetEmail 时,Firebase Api 将密码重置网址发送到我的电子邮件,但现在我必须获取验证码作为确认密码重置的参数。我想知道confirmPasswordReset函数中的“代码”来自哪里。(我在电子邮件中看不到代码,Firebase API 仅发送密码重置网址)
我有一个 WordPress 网站,并且激活的插件太多。所以我想知道我可以停用哪些插件。有没有相关的插件或者我应该一一检查?
我将为我的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文件而且无论如何都没有设置这个?最好的祝福
我将测试使用 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)
我不知道为什么它在标记时失败。奇怪的是,有时成功,有时失败。
谢谢
我已将此代码添加到 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() 函数的神奇作用。谢谢。
我将根据提供的密钥更新猫鼬文档的某些字段。例如,当我们在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. ...
谢谢
你好吗。我正在使用 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)
我究竟做错了什么?
谢谢