Giter Site home page Giter Site logo

joi-route-to-swagger's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

joi-route-to-swagger's Issues

Problem with optional params

Hi, guys,
I have the problems with the mapping Joi shemas to Swagger UI and I look for your advices :)

  1. Problem with the optional param
    As you can see below we have optional param "id".
    In case of request body - this parameter shouldn't be visible, because this "id" will be created under the hood.
    In case of response body - this parameter should be visible, because "id" was created at this time.
    I use this common schema both for request and response body:
export const BotSchema = Joi.object().keys({
    id: Joi.string().optional(),
    layout: Joi.number().required().label('bot.navigation.$.layout'),
    title: Joi.string().required().label('bot.navigation.$.title'),
    type: Joi.string().required(),
});

As a result - we can see "id" param in both cases - req and res:
image
What is a right way to working with this schemas?
Should I create different schemas - first for request body and second for response body?

  1. Problem with the incorrect display of the parameters.
    As you can see below I use the next schema for displaying request body:
    image

I see the next picture, but It's incorrect result (we have different types of field "data" depends on field "type".
image
What is a right way to configure this schemas for displaying correct result in Swagger UI?

Thanks in advance!

joi.when() is not working

For joi.when() schema proper swagger definition is not coming for example

Joi schema:-
myRequiredField: rm.joi.boolean(),
message: rm.joi.when('myRequiredField', {
is: true,
then: rm.joi.string(),
otherwise: rm.joi.number(),
})

Actual swagger definition:-
"myRequiredField": {
"type": "boolean",
"description": ""
},
"message": {
"type": [
"array",
"boolean",
"number",
"object",
"string",
"null"
],
"description": ""
}

Expected swagger definition:-

"myRequiredField": {
"type": "boolean",
"description": ""
},
"message": {
"properties": {
"oneOf": [
{
"type": "string"
},
{
"type": "number",
"format": "number"
}
]
}
}

Incorrect reference to entities

Hello,

The current version generates an incorrect reference in the entity defintion.

pet: {
   type: "object",
   description: "",
   schema: {
      $ref: "#/definitions/Pet"
   }
},

The correct version should be:

pet: {
   type: "object",
   description: "",
   $ref: "#/definitions/Pet"
},

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.