Is it possible to include an IP address in URL path? #2103
-
I asked this question on stack overflow but gotten no responses yet, so I apologize for the repetition. Using
---
openapi: 3.0.3
servers:
- url: /api
info:
version: 1
title: MyAPI
paths:
/echo/{ip}:
get:
x-mojo-to: Example#echo
parameters:
- name: ip
in: path
required: true
schema:
type: string
format: ipv4
responses:
'200':
description: OK
'500':
description: Internal Server Error
package MyApp;
use Mojo::Base 'Mojolicious', -signatures;
sub startup ($self) {
$self->plugin(OpenAPI => {url=>$self->home->rel_file("api.yaml")});
$self->plugin(SwaggerUI => {route=>$self->routes()->any('/swagger'),url=>"/api"});
}
1;
package MyApp::Controller::Example;
use Mojo::Base 'Mojolicious::Controller', -signatures;
sub echo($self) {
my $app = $self->openapi->valid_input or return;
my $input = $app->validation->output;
my $ip = $input->{ip};
$app->render(openapi=>{ip=>$ip});
}
1; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I imagine the issue is that the route being created is using a standard placeholder which don't parse anything after the dot. |
Beta Was this translation helpful? Give feedback.
I imagine the issue is that the route being created is using a standard placeholder which don't parse anything after the dot.
From looking at the docs for the plugin, it seems like you want to use the
x-mojo-placeholder
option to define which placeholder type you need