Coder Social home page Coder Social logo

oas-commons's Introduction

Commons Library

NPM

npm node-current npm Known Vulnerabilities Conventional Commits

About

OAS Devtools is an utility library for the development of new features and modules for oas-tools project. It provides functions and classes that helps to easily create new functionality for OAS Tools servers.

v1.0.0 Features

  • Error Classes:
    • ConfigError: Error class for configuration errors.
    • UnsupportedError: Error class for unsupported features.
    • ValidationError: Error class for validation errors.
    • RequestValidationError: Error class for client request validation errors.
    • ResponseValidationError: Error class for server response validation errors.
    • RoutingError: Error class for routing errors.
    • SecurityError: Error class for security errors.
    • AuthError: Error class for authentication errors.
  • Logger: Logger class built through composition over a winston logger.
  • Validator: Validation functions for OpenAPI Specification v3.
  • Middleware:
    • OASBase: Base class for all middlewares.

oas-commons's People

Contributors

alesancor1 avatar pebo avatar

Watchers

 avatar

Forkers

pebo rurikromanov

oas-commons's Issues

@oas-tools/commons 1.0.1 typings broken

Describe the bug

The content of index.d.ts is broken in the @oas-tools/commons v1.0.1 module:

node_modules/@oas-tools/commons/dist/index.d.ts
export * from "./middleware/index.js";
export * from "./utils/index.js";
export CHANGELOG.md LICENSE README.md dist node_modules package-lock.json package.json schemas src tsconfig.json typings from ../typings

The last line should not be there. The line was likely added by the build target in package.json which seem to include some early work on typescript migration:

    "build": "tsc && cp src/index.mjs dist/index.mjs && echo export * from '../typings' >> dist/index.d.ts",

To Reproduce

Steps to reproduce the behavior:

yarn build

Errors:

../../node_modules/@oas-tools/commons/dist/index.d.ts:3:1 - error TS1128: Declaration or statement expected.

3 export CHANGELOG.md LICENSE README.md dist node_modules package-lock.json package.json schemas src tsconfig.json typings from ../typings

...etc

Expected behavior

No extract lines in index.d.ts.

Screenshots

n/a

Desktop (please complete the following information):

n/a

Smartphone (please complete the following information):

n/a

Additional context

[BUG] Validator fails when response description is missing in API document

Hello,

First of all, thanks for the great library ๐Ÿ‘

Bug description

The oas-tools validator fails with an obscure message when the field "description" is missing in any "responses" field of the API document.
[oas-tools] ERROR: TypeError: s.replaceAll is not a function

To Reproduce

Steps to reproduce the behavior:

  1. Initialize a project of type "server" with the following API file and the default configuration
openapi: "3.1.0"
info:
  version: 1.0.0
  title: Sample API
servers:
  - url: http://localhost:9876
paths:
  /test:
    x-router-controller: controller
    get:
      operationId: test
      responses:
        200:
          description: Sample description  # <--- Line to remove
          content:
            application/json:    
              schema:
                type: object
  1. Run the server with npm start. No error appears
  2. Remove the "description" line in the API file
  3. Run the server again. The following error appears:
2022-09-24 18:09:83 [oas-tools] ERROR: TypeError: s.replaceAll is not a function
    at _____\node_modules\@oas-tools\commons\dist\utils\modules\validator.js:40:131

Expected behavior

The validator should ignore the missing field, or give a clearer message about the missing field

According to the OAS spec, the description field is optional:

Operations also support some optional elements for documentation purposes:

  • A short summary and a longer description of what an operation does. description can be multi-line and supports Markdown for rich text representation.
  • ...

https://swagger.io/docs/specification/paths-and-operations/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.