Skip to content

md-web-server/simp-example-swaggerize-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple implementation of design driven api npm swaggerize-express

Preliminary instructions,

npm install -g yo
npm install -g generator-swaggerize

NOTE: now, generate an openapi.json example NOTE: running yo swaggerize will prompt for such a document. NOTE: programmers will look at the openapi.json to make changes NOTE: or understand the service

git clone https://github.com/MichaelDimmitt/simp-example-swaggerize-express.git;
cd simp-example-swaggerize-express
yo swaggerize

*when prompted input:* openapi.json
for testing purposes, answer all additional questions with "fred" -will still work.
cd fred

How it works,

Handler

  cd into (app name)
  cd into handler folder
  NOTE: handler folder is your request comes in and your response ships out.
  GET REQUESTS:
  request, stored as "req" comes from the url where key and value queries are communicated.
  response, stored as "res" 

Config and getting it running

by default config/swagger.json
has all the answers for the backend developer
this is your api 
or as the autogenerated readme declares, 
Swagger api [location](./fred/config/swagger.json)

  Three sections make up this example url, http://localhost:8000/v1/pets?limit=10

    base-url
      notice baseURL in this case is v1
    paths
      notice path in this case is pets
    parameters
      notice parameter in this case is 
      "name": "limit",

Running the application

cd fred 
open http://localhost:8000/v1/pets?limit=10; npm start

Up next

  consuming these endpoints, I am considering keeping all of this in the same repo.
  the api autogenerates in a subfolder. 
    therefore the rationale is the consumer as an adjacent folder.

  eager for feedback.
  elsewise the consumer could exist in another repo.

Additional Ramblings/ things you should know;

req ... comes in as an object whose keys can be accessed with "."'s

instead of the entire request object.
ofen req.query is used. req.pathname leads to the autocreated handler file and therefore not always required.
for your viewing purposes, a full req object availiable in the repo folder.

This is most simular to web scraping objects.
in that the whole object is not required but everything is given.

you can add a new handler by modifying config/swagger.json
adding the path and then adding the file that would correspond with that path.

About

simple implementation design driven api npm [swaggerize-express](https://www.npmjs.com/package/swaggerize-express)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published