-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow to define Schema Object in Server variables #597
feat: allow to define Schema Object in Server variables #597
Conversation
Kudos, SonarCloud Quality Gate passed! |
I think we'll need to specify how to serialize them to strings (probably on channel parameters too) so when someone does something like this: variables:
example:
schema:
type: object
properties:
a:
type: string
default: 'hello' How is it serialized into the URL? As The reason you don't have a full schema object is to prevent people from using other things than a simple string. We can probably improve it and let people use other basic types like Food for thought 🤔 |
Also, is there a use case driving this proposal? Would be great to know why you want such a change. |
I know that
I don't think so if it should be serialized. In my opinion it's invalid. Like in Parameter Object, currently you have this possibility to define parameter as object (or array), but it's invalid usage, so we should also handled that problem in this proposal, for Server Variable and Parameter Object.
I don't have (for me) explicit use case, but I see that at the moment if you want define more specific constraints for your Server Variable, you must write examples in the variable:
type: integer
minimum: 0
maximum: 100 rather than: variable:
examples: ['0', '1', '2' ... '100']
# or:
enum: ['0', '1', '2' .... '100'] So at the end (after discussion) we should have answer for question: allow all keywords for the Server Variables? If yes, fine, if not, then we should chose the most important and change also the schema shape for Channel Parameter Object. |
I am now wondering if in server url user should have possibility to define query for configuration purposes 🤔 This may be off-proposal but it is quite an interesting topic. |
@fmvilas what do you mean by For now I don't like it is not a specific use case driven, but still it is a good change that makes Variables consistent with Parameters. I would compare it to #547, so like, nobody cares much (I mean, it is like it is, and things still work), but the change makes sense and we should strongly consider it. Nevertheless, would be cool to hear community here. |
Yeah, sorry I should have been clearer. I meant what actual strings in the URL should be matching the validation described in the schema. So for instance, if you have a URL template like variables:
username:
schema:
type: array If so, why are we assuming that URL variables should be deserialized as JSON? Why not a list of values like My point is, don't you think it's weird? And don't get me wrong, I think we should align with Parameter Object but probably by removing the Of course, listening from the community would be needed here. Maybe nobody is using the schema keyword beyond |
I agree with you that's it's weird that in the current proposal you can define also the But however if I define for headers the it still works. I know that spec =/= tooling (parser) but we should handle that problems. |
very good point.
Strange, I was fixing it in the schema in the past and it was working as expected -> asyncapi/spec-json-schemas#10 Yeah, just fix the schema here https://github.com/asyncapi/asyncapi-node/blob/master/schemas/2.1.0.json#L644-L657 😄 |
@derberg Sorry, you're right, if you define another type that I will create an issue in the EDIT: Issue -> asyncapi/spec-json-schemas#82 |
Yeah, I agree we should standardize it. I just don't agree to extend server variables but "cut" the parameters object instead. It's weird in both places. And regarding headers, you're right, it's another example. The reason it is like that is that I couldn't find a better way to do it. In this case (including the Parameter Object case), I think our best choice is to actually remove options to keep it simple. My two cents. |
This pull request has been automatically marked as stale because it has not had recent activity 😴 |
Still valid. We will need this in the next major release. |
+1 @magicmatatjahu would it make sense to turn this issue scope into what that suggestion says? |
@smoya but in ParameterObject you have also |
What I understood (maybe wrongly) with that suggestion is that we drop support completely for using Schema Object (and |
And how people will define constraints for parameter? 😅 Looking at this idea, removing the |
No idea. I thought this was part of what it should be done. But as I mentioned, I think I did a wrong assumption so please discard it :) |
This pull request has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
At the moment, I don't see the point of keeping that PR open. If I find another way to use Schema Object in Server Variable, I will make an another proposal. |
title: "Allow to define Schema Object in Server variables"
Related issue(s):
#583
As I described in the #583 issue, I'm wondering why we have inconsistencies for schemas in
server.variables
andchannel.parameters
. This PR introduces change of shape of single Server Variable Object:instead of having the 3 words
enum
,default
,examples
, which work identically to the JSON Schema keywords, we will now have the wordschema
, which is Schema Objectdescription
is still available, to be consistent with Channel Parameter Object.we can remove
description
field (it is also defined in Schema Object) and flat theschema
so definition of single variable can have shape like:another solution is to add the possibility to define other keywords like
format
,pattern
,minLength
etc and for numeric values (integer and number types), but in the current proposal someone can define a schema for server variable incomponents/schemas
and we are reusing things that already exist in spec, not creating something from scratch.with current proposal, in the future, when we will implement and resolve problems (Avro schemas are not supported in the components/schemas section #528 [2.0.0 REVIEW] Clarify usage of JSON References (/Pointers) for non-JSON data structures #216), user will be able to define variables in different formats than JSON Schema.
Comments are more than welcome!
BTW. It's a breaking change, so it should be (hopefully) merged in the
3.0.0
.