oas-tools / oas-cli Goto Github PK
View Code? Open in Web Editor NEWCommand line interface tool for OAS TOOLS Framework
License: Apache License 2.0
Command line interface tool for OAS TOOLS Framework
License: Apache License 2.0
When initializing a new server using the CLI tool, if the option to generate the Dockerfile is set the server will throw an error when executing npm start
:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'server.js' imported from E:\Alex\Desktop\adsdsd\generated-server\index.js
at new NodeError (node:internal/errors:371:5)
at packageResolve (node:internal/modules/esm/resolve:884:9)
at moduleResolve (node:internal/modules/esm/resolve:929:18)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Steps to reproduce the behavior:
npx @oas-tools/cli init
and select server
npm start
inside the new server directory.The server should start normally, installing all dependencies previously.
Describe the bug
When we declare arrays inside the entities and execute the cli for the creation of the oas-doc from a json. These are taken as their type in javascript typeof [1,2,3,4] // Returns "object".
To Reproduce
Steps to reproduce the behavior:
[
{
"id": 1,
"name": "User",
"email": "[email protected]",
"pets": [
{
"id": 1,
"petName": "Garfield",
"type": "Cat"
}
]
}
]
npx @oas-tools/cli init
to create OpenAPI FileWhen generating a server with the CLI, the default configuration included in index.js does not specify the OAS file the server was generated from.
The validation that oas-tools perform expects that, if no oas file is specificied in the configuration object passed to the initialize function, the default OAS file will be at api/oas-file.yaml. However, the CLI generates it as api/oas-doc.yaml, causing an initialization error as a consequence if no explicit config is provided.
It would be better to sync somehow the two default names both in CLI and in core modules.
When generating an OpenAPI document from an entity resource file, the 204 status is the only one that is generated as a string instead of as an integer.
Other (non-204) response statuses look like the following:
responses:
200:
description: Item found by id
For 204s, it will instead look like this:
responses:
"204":
description: Item deleted
Steps to reproduce the behavior:
Instead of "204"
, the status should simply be 204
(no quotation marks).
Awkward phrasing in serverPrompt and filePrompt
Steps to reproduce the behavior:
Steps to reproduce the behavior:
A clear and concise message explaining what will happen.
None.
oas-cli/templates/server/index.js.hbs
Line 61 in 7d9e6b2
the line should display the output if disable !== true
in stead of false
Using the CLI to generate an OpenAPI document from an entity resource file for a given resource like User
.
The CLI generates the following lines containing an operationId
that should probably be plural:
/api/v1/users:
get:
description: Returns all users
operationId: getUser
responses:
200:
description: User list
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
Note how the endpoint and description are plural as expected, and the success response is an array, yet the operationId
is singular.
In turn, when generating a server based on this OpenAPI document, we'll end up with a controller that looks like this:
export function getUser(req, res) {
service.getUser(req, res);
}
The function name would seem to imply that we'll only be getting one user back. However, the return value is going to be an array with any number of users.
Instead of getUser
, the operation should be named getUsers
.
I haven't done a thorough check, but this appears to be where it's happening:
oas-cli/templates/file/oas-doc.hbs
Lines 13 to 14 in bf53dd6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.