Comments (7)
Given that spot is specifying the
oas3
prefix, should there be any checks, of spot generates a specification below oas3? Or would specifyingoas
would be enough?
Spot supports conversion to the 2 major versions of OpenAPI specs (2 & 3). To reduce any false assumptions I think:
oas*
- can be understood by both v2 and v3oas2*
- understood only by v2oas3*
- understood only by v3
Does
OAS
need to specified internally for the variablesoas3serverVariables
?
I think keeping the prefix helps to communicate the intended usage for the annotation. It also allows Spot core annotations to reserve the unprefixed @serverVariables
annotation for its own purposes.
If
@default
is missing, does the specification then not have adefault
value?
I would expect the Spot parser to complain about a missing @default
and consider the contract invalid.
Alternatively we can also consider the following syntax:
@api({
name: "My API",
version: '1'
})
class Api {
/**
* The production API server
*/
@oa3server({ url: "https://{username}.gigantic-server.com:{port}/{basePath}" })
productionServer(
/** this value is assigned by the service provider, in this example `gigantic-server.com` */
@oa3serverVariable({ default: "demo" })
username: String,
@oa3serverVariable({ default: "8443" })
port: "8443" | "443",
@oa3serverVariable({ default: "v2" })
basePath: String
) {}
}
or even:
@api({
name: "My API",
version: '1'
})
class Api {
/**
* The production API server
*/
@oa3server({ url: "https://{username}.gigantic-server.com:{port}/{basePath}" })
productionServer(
/** this value is assigned by the service provider, in this example `gigantic-server.com` */
@oa3serverVariable
username: String = "demo",
@oa3serverVariable
port: "8443" | "443" = "8443",
@oa3serverVariable
basePath: String = "v2"
) {}
}
I'm not a huge fan of either though since we can't use the same strategy for types/schemas, whereas jsDoc @default
tags can be easily used on any kind of Typescript element.
from spot.
@oben01 I might pick this up sometime next week, unless @mahirk has made a start on this?
from spot.
To keep you posted I am working on this feature
from spot.
Server objects are OpenAPI 3 spec specific metadata. I'm thinking spec specific definitions should be prefixed for example @oa3server
or @openapi3server
rather than @server
.
Using the following example from Server Object Example
{
"servers": [
{
"url": "https://{username}.gigantic-server.com:{port}/{basePath}",
"description": "The production API server",
"variables": {
"username": {
"default": "demo",
"description": "this value is assigned by the service provider, in this example `gigantic-server.com`"
},
"port": {
"enum": [
"8443",
"443"
],
"default": "8443"
},
"basePath": {
"default": "v2"
}
}
}
]
}
What do you think of the following syntax?
@api({
name: "My API",
version: '1'
})
class Api {
/**
* The production API server
*/
@oa3server({ url: "https://{username}.gigantic-server.com:{port}/{basePath}" })
productionServer(
@oa3serverVariables
variables: {
/**
* this value is assigned by the service provider, in this example `gigantic-server.com`
*
* @default "demo"
*/
username: String,
/**
* @default "8443"
*/
port: "8443" | "443",
/**
* @default "v2"
*/
basePath: String
}
) {}
}
@oa3server
can be declared multiple times to set multiple serversurl
encapsulated as part of the annotation for consistency with the@endpoint
annotation
- Standard
@default
jsDoc tag to specify default values rather than relying on any implicit value
Some other questions:
- Should variables allow anything but
string
types? e.g. port could be represented asInteger
instead to convey intent- This would be converted back to string representations though when converted back to OpenAPI, so could seem like wasted effort for little gain
from spot.
I like that. I have a few questions, to understand the decorator usage primarily:
Given that spot is specifying the oas3
prefix, should there be any checks, of spot generates a specification below oas3? Or would specifying oas
would be enough? Does OAS
need to specified internally for the variables oa3serverVariables
?
If @default
is missing, does the specification then not have a default
value?
Should variables allow anything but string types?
I think having everything as the string would be ideal in the longer term. I agree with your note there.
from spot.
Thank you! I'll work on this, unless someone else picks it up after completing the examples for the other parameters (#916 (comment)) and #1034
from spot.
Hello,
Do we got any update ?
from spot.
Related Issues (20)
- Documentation for how to use non-required/optional body parameters HOT 2
- @oaSchemaProp example fails with numerical strings HOT 6
- Use openapi-types?
- Add support for HEAD methods HOT 5
- OA3 Types Not Exported in Root Package
- Support for Template Literal Strings
- Support for grouping tags with x-tagGroups
- Not possible to use custom methods in paths
- Missing exports of oa3serverVariables & oa3server HOT 4
- Support for OpenAPI features like maxLength, format, default HOT 2
- Default oaSchemaProp on Enum Strings throws an error HOT 1
- Support Duplicate Header Keys
- Add ability to pass `deprecated: true` to @endpoints config
- Support for blobs
- Generation failed on the example spec when in yarn workspace HOT 1
- Nullable object fields don't get generated correctly HOT 1
- Spot doesn't work in a monorepo HOT 4
- UI for Spot
- Method parameter decorators cause typescript build to fail.
- Your Customer Support Sucks!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spot.