1.2.4 • Published 7 years ago

swagger-definitions-to-react-proptypes v1.2.4

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

swagger-definitions-to-react-proptypes

CLI that consumes a swagger endpoint and spits out React propType definitions.

Installation:

npm install -g swagger-definitions-to-react-proptypes

or

yarn add --dev swagger-definitions-to-react-proptypes

Usage:

swagger-definitions-to-react-proptypes http://petstore.swagger.io/v2/swagger.json

swagger-definitions-to-react-proptypes ./swagger.yml

./node_modules/bin/swagger-definitions-to-react-proptypes ./swagger.yml ./src/definitions.js

/**
Generated PropTypes for http://127.0.0.1:1337/petstore-v2.0.json
**/

import PropTypes from "prop-types";


export const Order = PropTypes.shape({
    id: PropTypes.number,
    petId: PropTypes.number,
    quantity: PropTypes.number,
    shipDate: PropTypes.date,
    status: PropTypes.oneOf([
        "placed",
        "approved",
        "delivered"
    ]),
    complete: PropTypes.bool
});

export const Category = PropTypes.shape({
    id: PropTypes.number,
    name: PropTypes.string
});

export const User = PropTypes.shape({
    id: PropTypes.number,
    username: PropTypes.string,
    firstName: PropTypes.string,
    lastName: PropTypes.string,
    email: PropTypes.string,
    password: PropTypes.string,
    phone: PropTypes.string,
    userStatus: PropTypes.number
});

export const Tag = PropTypes.shape({
    id: PropTypes.number,
    name: PropTypes.string
});

export const ApiResponse = PropTypes.shape({
    code: PropTypes.number,
    type: PropTypes.string,
    message: PropTypes.string
});

export const Pet = PropTypes.shape({
    id: PropTypes.number,
    category: PropTypes.shape({
        id: PropTypes.number,
        name: PropTypes.string
    }),
    name: PropTypes.string.isRequired,
    photoUrls: PropTypes.arrayOf(PropTypes.string).isRequired,
    tags: PropTypes.arrayOf(PropTypes.shape({
        id: PropTypes.number,
        name: PropTypes.string
    })),
    status: PropTypes.oneOf([
        "available",
        "pending",
        "sold"
    ]),
    createdAt: PropTypes.date
});
1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago