SWAGGER(6)
-
Nest Swagger 4. 재 사용성 높히기
Property 예시 값 생성 : https://crispypotato.tistory.com/199 Responese 예시 값 생성 : https://crispypotato.tistory.com/201 사용 이유 : 두 개의 Swagger 기능을 만들면 예시 값이 중복되는 코드가 생긴다. 그 때 schame(model)에 property 값을 넣어 중복되는 코드를 제거 할 수 있다. 사용 방법 : test.model.ts 파일에서 import 하여 DTO 파일에서 ApiProperty를 작성 한 것과 같이 작성해 준다. import { ApiProperty } from '@nestjs/swagger'; ///test.model.ts import { Prop, Schema, SchemaFactory, Sc..
2022.04.21 -
Nest Swagger 3. [ Response 생성]
세팅과 기본 설정 : https://crispypotato.tistory.com/199 Nest Swagger 1. 사용 방법 [ 세팅, summary 생성, property 생성 ] 1. 설치 2. 첫 swagger 세팅 3. api summary, property생성 1. 설치 npm install --save @nestjs/swagger swagger-ui-express 2. 첫 세팅 main.ts에서 bootstrap() 함수에 swagger를 추가 해준다. import { NestFa.. crispypotato.tistory.com 만드는 이유 : 기본적으로 summary, property를 설정해도 다른 개발자는 요청 하며 작업을 진행 할 수 있다. 하지만 요청 작업하기 힘든 상황이거나, 요청..
2022.04.21 -
Nest Swagger 2. Swagger 사용 방법 [ 비밀번호 생성 ]
실제 Production에서 Swagger를 아무나 접속을 할 수 있게 하면 큰 보안적 위험이있다. 그래서 로그인을 비밀번호를 만들어서 접근을 제한 해야한다. 1. 설치 npm i express-basic-auth 2. 사용 방법 접근하는 아이디, 비밀번호는 .env 환경변수에 저장한다 .env 파일 사용 방법 : https://crispypotato.tistory.com/194 main.ts에서 express-basic-auth를 import해서 사용한다. ///main.ts import { ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { SwaggerModule, DocumentBui..
2022.04.20 -
Nest Swagger 1. 사용 방법 [ 세팅, summary 생성, property 생성 ]
1. 설치 2. 첫 swagger 세팅 3. api summary, property생성 1. 설치 npm install --save @nestjs/swagger swagger-ui-express 2. 첫 세팅 main.ts에서 bootstrap() 함수에 swagger를 추가 해준다. import { NestFactory } from '@nestjs/core'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); const co..
2022.04.20 -
swagger 긴 주석 작성 방법 (yaml파일) 줄 바꿈, 글씨 강조
swagger 작성 시 설명 해야하는게 많을 경우 주석이 길어지는데 이는 주석의 가독성이 떨어진다. 그래서 강조, 한 줄 내리기 등 표시를 해가며 나타내어야 한다. yaml파일을 사용했다. description 에서 수정한다. description 에서 | 가 중요하다. 꼭 있어야 하니 기억하자. 1. 줄 바꿈 문장이 끝나고 공백 두번을 넣으면 줄 바꿈이 된다. description: | Pet Store APIs This is a sample Petstore server Contains API Note: to manage the pet store 2. 글씨 강조, 기울임꼴 하기 ** , __ 로 묶으면 해당하는 글씨가 강조가 된다. _ 로 묶으면 기울임꼴이 된다. description: | **Pet*..
2022.01.03 -
Azure에서 swagger Content Security Policy directive: "img-src img.icons8.com 오류 해결법
우리가 로컬 상에서 csp 설정, cors 설정을 해주었는데도 막상 배포가 완료된 Azure Web Service 에서는 오류가 발생한다. 왜냐하면 해당 web service에 있는 cors설정 를 변경해주어야 한다! 본인의 웹사이트를 입력/저장 해주면 정상적으로 작동한다.
2021.08.18