Postman으로 API 만들기
동기 부여
모처럼 Postman에서 API 테스트를하고 있기 때문에, 간단한 API를 만들어 보자는 이야기
POSTMAN Learning Center 님입니다.
참고문헌
Using the API Builder
절차
Postman에는 API builder라는 기능이있는 것 같습니다.
(비어있는) API 만들기
Postman Desktop App의 왼쪽 창에서 API를 선택 → 메뉴에서 Create an API를 클릭하십시오.

모달이 표시되므로 기본 정보를 입력/선택하고 Create API 버튼을 클릭합니다.
API 이름
버전
스키마
스키마 형식
my-first-api
1.0.0
OpenAPI 3.0
JSON

↓↓와 같은 느낌이 되면, 우선 OK라고 생각한다:

API 정의
API를 정의한다. Postman에는 정의한 API에서 자동으로 collection을 생성하는 기능도 있는 것 같다.
API 수정
작성한 API의 사양은 Define 탭에 기재하는 것 같다.
이번에는 OpenAPI 3.0을 스키마로 설정했기 때문에 Postman이 샘플 API 사양을 만들어 준다.
편집이 끝나면 저장 버튼을 클릭하여 저장합니다.

Define 탭에 기본적으로 입력되는 API 사양
sample-spec.json{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "my-first-api",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/user": {
"get": {
"summary": "Details about a user",
"operationId": "listUser",
"tags": [
"user"
],
"parameters": [
{
"name": "id",
"in": "query",
"description": "ID of the user",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Details about a user",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
만든 API에서 collection 생성
작성한 API 문서를 작성하고, 테스트를 작성하고, 모의 서버를 작성하려면 Generate Collection 기능을 사용하십시오.
창 오른쪽에 Generate Collection 버튼이 있으므로 클릭하십시오.

모달이 표시되므로 Collection 이름을 입력하고 용도를 선택합니다.

Generate Collection 버튼을 클릭하면 collection이 생성된다.
이번에는 용도로 'Test the API'를 선택했습니다.

비고
모의 서버를 만들 수는 있지만, 호출 횟수에는 제한이 있다(무료 플랜이라면, 월간 1,000회까지).
현재 통화 횟수는 Add-ons에서 확인할 수 있습니다.
htps : // 우ぇ b. 포스트 만. 코 / 흠 g / 아 d 온 s / 오 ょ r ゔ 아 w
Reference
이 문제에 관하여(Postman으로 API 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/hideshis/items/a00d62160470cc5e2494
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Using the API Builder
절차
Postman에는 API builder라는 기능이있는 것 같습니다.
(비어있는) API 만들기
Postman Desktop App의 왼쪽 창에서 API를 선택 → 메뉴에서 Create an API를 클릭하십시오.

모달이 표시되므로 기본 정보를 입력/선택하고 Create API 버튼을 클릭합니다.
API 이름
버전
스키마
스키마 형식
my-first-api
1.0.0
OpenAPI 3.0
JSON

↓↓와 같은 느낌이 되면, 우선 OK라고 생각한다:

API 정의
API를 정의한다. Postman에는 정의한 API에서 자동으로 collection을 생성하는 기능도 있는 것 같다.
API 수정
작성한 API의 사양은 Define 탭에 기재하는 것 같다.
이번에는 OpenAPI 3.0을 스키마로 설정했기 때문에 Postman이 샘플 API 사양을 만들어 준다.
편집이 끝나면 저장 버튼을 클릭하여 저장합니다.

Define 탭에 기본적으로 입력되는 API 사양
sample-spec.json{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "my-first-api",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/user": {
"get": {
"summary": "Details about a user",
"operationId": "listUser",
"tags": [
"user"
],
"parameters": [
{
"name": "id",
"in": "query",
"description": "ID of the user",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Details about a user",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
만든 API에서 collection 생성
작성한 API 문서를 작성하고, 테스트를 작성하고, 모의 서버를 작성하려면 Generate Collection 기능을 사용하십시오.
창 오른쪽에 Generate Collection 버튼이 있으므로 클릭하십시오.

모달이 표시되므로 Collection 이름을 입력하고 용도를 선택합니다.

Generate Collection 버튼을 클릭하면 collection이 생성된다.
이번에는 용도로 'Test the API'를 선택했습니다.

비고
모의 서버를 만들 수는 있지만, 호출 횟수에는 제한이 있다(무료 플랜이라면, 월간 1,000회까지).
현재 통화 횟수는 Add-ons에서 확인할 수 있습니다.
htps : // 우ぇ b. 포스트 만. 코 / 흠 g / 아 d 온 s / 오 ょ r ゔ 아 w
Reference
이 문제에 관하여(Postman으로 API 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/hideshis/items/a00d62160470cc5e2494
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "my-first-api",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/user": {
"get": {
"summary": "Details about a user",
"operationId": "listUser",
"tags": [
"user"
],
"parameters": [
{
"name": "id",
"in": "query",
"description": "ID of the user",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Details about a user",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"User": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"Error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}
}
모의 서버를 만들 수는 있지만, 호출 횟수에는 제한이 있다(무료 플랜이라면, 월간 1,000회까지).
현재 통화 횟수는 Add-ons에서 확인할 수 있습니다.
htps : // 우ぇ b. 포스트 만. 코 / 흠 g / 아 d 온 s / 오 ょ r ゔ 아 w
Reference
이 문제에 관하여(Postman으로 API 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hideshis/items/a00d62160470cc5e2494텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)