npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

swagger-protobuf-ui

v1.1.0

Published

swagger-ui-bundle communicating by protobuf

Readme

swagger-protobuf-ui-bundle

swagger-ui-bundle communicating by protobuf

개발

의존성 설치

npm install

주요 스크립트

  • npm run start
    • 개발용 웹팩 서버를 실행합니다.
  • npm run build
    • 프로덕션용으로 번들링합니다.
  • npm run build:lite
    • 프로덕션용(lite버전)으로 번들링합니다.
  • npm run test
    • Jest를 사용하여 단위 테스트를 실행합니다.
  • npm run lint
    • ESLint로 코드 스타일을 검사합니다.
  • npm run prettier:check
    • Prettier로 코드 포맷팅을 검사합니다.
  • npm run e2e
    • Playwright로 E2E 테스트를 실행합니다.

빌드 파일

  • 기본 버전
    • swagger-protobuf-core.js
    • swagger-ui-bundle.js이 포함된 파일
  • Lite 버전
    • swagger-protobuf-lite.js
    • swagger-ui-bundle.js를 포함하지 않은 경량화 파일

예시

Swagger 웹 예시

예시폴더

./example/web

필수 import 파일

index.html

<body>
    <!-- ... -->
    <script src="./proto/proto.bundle.js"></script>
    <script src="./swagger-initializer.js" charset="UTF-8"> </script>
</body>

SwaggerProtoBufUIBundle

SwaggerUIBundle를 대체하여 SwaggerUI를 생성해주는 함수

예시파일

swagger-initializer.js

매개변수

  1. ProtoLibraryObject
    • 프로토버퍼로 생성된 js번들에서 사용되는 전역변수
  2. Options
    • SwaggerUiBundle의 Options와 동일함
window.onload = function() {
	window.ui = SwaggerProtoBufUIBundle(ProtoLibraryObject,{
        url : "http://localhost/swagger-config.json",
        dom_id: '#swagger-ui',
        presets: [
            SwaggerUIBundle.presets.apis,
            SwaggerUIStandalonePreset
        ],
    });
};

Swagger/OpenApi 정의 사양 설정 방법

요청과 응답에 필요한 Proto.Message는 아래의 키로 설정해야함.

예시파일

server.json

  1. req_message
    • 요청에 사용되는 Message 키
    • Method안에 정의
  2. res_message
    • 응답에 사용되는 Message 키
    • Method안에 정의
...
"/users": {
    "post": {
        "summary": "새로운 사용자 생성",
        "description": "JSON 형식으로 사용자 정보를 받아 새 사용자를 생성하고, 생성된 사용자 정보를 Protobuf 형식으로 반환합니다.",
        "tags": ["Users"],
        "req_message" : "User",
        "res_message" : "User",
        ...
    }
}
...

프로토버퍼 컴파일 예시

프로토버퍼(.proto)를 사용하여 JavaScript(bundle.js)를 만든 예제 example/protobuf에 예제가 있습니다.

서버 예시

프로토버퍼를 컴파일한 bundle.js를 사용하여 만든 api서버 예제 example/server에 예제가 있습니다.

Acknowledgements

This project uses the following open source software:

  • Swagger UI (Apache License 2.0)
  • Google Protocol Buffers (BSD 3-Clause License)