GithubHelp home page GithubHelp logo

ujjwalguptaofficial / fortjs-swagger Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 8.09 MB

Swagger module for fortjs

Home Page: http://fortjs.info/tutorial/swagger/

License: GNU General Public License v3.0

TypeScript 89.90% JavaScript 6.71% HTML 3.38%
fortjs fortjs-swagger javascript openapi swagger swagger-api swagger-codegen swagger-generator typescript

fortjs-swagger's People

Contributors

dependabot[bot] avatar ujjwalguptaofficial avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

fortjs-swagger's Issues

Property with nested modeling not working

export class User implements SwaggerModel {
    @OptionalProperty
    name: string
    password: string
    friends: Friend[]

    @IgnoreProperty
    init?(user: any) {
        this.name = user.name
        this.password = user.password
        this.friends = user.friends
    }

    getExample?() {
        this.name = "name"
        this.password = "password"
        // Problem seems to be related to nested classes. 
        // If I include User here it won't throw an error but it also won't show up as a property on the swagger page.
        this.friends = [new Friend()]
    }
}

xport class Friend implements SwaggerModel {
    @OptionalProperty
    name: string

    @IgnoreProperty
    init?(user: any) {
        this.name = user.name
    }

    getExample?() {
        this.name = "name"
    }
}

The friend property is not being added in swagger doc

@TimWelter

Swagger documentation

I feel like the swagger documentation isn't very detailed.
For example it doesn't actually show you how you need to write the swagger classes.

I have this right now and it just throws an error:

class Component implements SwaggerModel {
    @OptionalProperty
    name: string;
    completed: boolean;
    manNr: string;
    comment: string;
    specialAttribute: string;
    specialAttrValue: string;
    instructionImg: string;

    @IgnoreProperty
    init?(component: any) {
        this.name = component.name;
        this.completed = component.completed;
        this.manNr = component.manNr;
        this.comment = component.comment;
        this.specialAttribute = component.specialAttribute;
        this.specialAttrValue = component.specialAttrValue;
        this.instructionImg = component.instructionImg;
    }

    getExample?() {
        this.name = "component_name"
        this.completed = false
        this.manNr = "1234"
        this.comment = "comment"
        this.specialAttribute = "NONE"
        this.specialAttrValue = "value"
        this.instructionImg = "img.png"

    }
}

class Step implements SwaggerModel {
    @OptionalProperty
    _id: string
    name: string
    index: number
    completed: boolean
    components: Component[]

    @IgnoreProperty
    init?(step: any) {
        this.name = step.name;
        this.index = step.index;
        this.completed = step.completed;
        this.components = step.components
    }

    getExample?() {
        this.name = "step_name"
        this.index = 1
        this.completed = false
        this.components = [new Component()]
    }
}

export class Order implements SwaggerModel {
    @OptionalProperty
    _id: string
    serialNumber: string
    productionOrder: string
    articleNumber: string
    model: string
    assemblySteps: Step[]
    testingSteps: Step[]
    packingSteps: Step[]
    startDate: number
    endDate: number
    complete: boolean
    timer: number
    paused: boolean
    started: boolean

    @IgnoreProperty
    init?(order: any) {
        this._id = order._id
        this.serialNumber = order.serialNumber
        this.productionOrder = order.productionOrder
        this.articleNumber = order.articleNumber
        this.model = order.model
        this.assemblySteps = order.assemblySteps
        this.testingSteps = order.testingSteps
        this.packingSteps = order.packingSteps
        this.startDate = order.startDate
        this.endDate = order.endDate
        this.complete = order.complete
        this.timer = order.timer
        this.paused = order.paused
        this.started = order.started
    }

    getExample?() {
        this._id = "123456789"
        this.serialNumber = "123456789"
        this.productionOrder = "123456789"
        this.serialNumber = "123456789"
        this.model = "model_name"
        this.assemblySteps = [new Step()]
        this.testingSteps = [new Step()]
        this.packingSteps = [new Step()]
        this.startDate = Date.now()
        this.endDate = Date.now()
        this.timer = 0
        this.complete = false
        this.paused = false
        this.started = false
    }
}

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.