{braces} in ServerVariables not getting replaced
Describe the bug
Following this article: https://www.asyncapi.com/docs/concepts/asyncapi-document/variable-url
The Variables in {braces} dont get replaced.
To Reproduce
Steps to reproduce the behavior:
- Create a yaml file. (See Sample Document)
- Generate the HTML:
asyncapi generate fromTemplate file.yaml @asyncapi/[email protected] -o example --use-new-generator
Expected behavior
A Document with replaced {braces}
Sample document
asyncapi: 3.0.0
info:
title: Example API
version: '1.0.0'
servers:
production:
host: '{subdomain}.example.com:{port}'
pathname: '/{version}'
protocol: amqp
variables:
subdomain:
$ref: '#/components/serverVariables/subdomain'
port:
$ref: '#/components/serverVariables/port'
version:
$ref: '#/components/serverVariables/version'
development:
host: '{subdomain}.dev.example.com:{port}'
pathname: /v1
protocol: amqp
variables:
subdomain:
$ref: '#/components/serverVariables/subdomain'
port:
$ref: '#/components/serverVariables/port'
version:
$ref: '#/components/serverVariables/version'
components:
serverVariables:
subdomain:
enum:
- development
- staging
- production
default: development
port:
default: '8080'
version:
enum:
- v1
- v2
Screenshots
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
related to react-component - moving the issue there
@butilka123 it would make sense to explain here in the issue to maintainers of react-component, what would you see the braces are replaced with
/ti asyncapi-react
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
related to react-component - moving the issue there
@butilka123 it would make sense to explain here in the issue to maintainers of react-component, what would you see the braces are replaced with
I am very new to AsyncAPI itself, but in my example I would expect that the braces get replaced with the corresponding variables.
Thank you for moving the issue.
to fix this issue , what would be the correct approach to begin with ?
I don't think it requires a fix. If we replace braces with default value then how reader of such generated docs knows where to put other allowed values, if there are no placeholder/braces
I don't think it requires a fix. If we replace braces with default value then how reader of such generated docs knows where to put other allowed values, if there are no placeholder/braces
The Idea is that you define 1x Variables and re-use it.
(I accedentally closed the issue)
yeah, cross verified it and it's a feature, not a bug.
the braces are actually supposed to be shown in the URL display because they indicate the placeholder positions for the variables. The format {variable} is the standard AsyncAPI way to show where variables will be interpolated in the URL.
When the actual connection is made, these variables would be replaced with their actual values based on the serverVariables definitions in your components section. For example:
{subdomain} could become "development", "staging", or "production"
{port} would become "8080" by default
{version} would become either "v1" or "v2"
I don't think it requires a fix. If we replace braces with default value then how reader of such generated docs knows where to put other allowed values, if there are no placeholder/braces
The Idea is that you define 1x Variables and re-use it.
(I accedentally closed the issue)
@butilka123 can you elaborate on what you mean by define 1x Variables and re-use it?
The Idea is that you define 1x Variables and re-use it.