Skip to content
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

path specific URL endpoint using server object url #1356

Closed
jeevarajan opened this issue Sep 26, 2017 · 11 comments
Closed

path specific URL endpoint using server object url #1356

jeevarajan opened this issue Sep 26, 2017 · 11 comments

Comments

@jeevarajan
Copy link

jeevarajan commented Sep 26, 2017

In below given example, i need to have customized url for the resource "user-enableuser". i thought in openapi 3.0.0, it can be achieved through server object for each path. Please let me know what i am missing here

"paths": {
    "/user-enableuser": {
      "post": {
		"servers": [{
			"url": "https://x.x.x.x/user"
		}],
        "tags": [
          "user"
        ],
        "summary": " ",
        "operationId": "user@ENABLE",
        "produces": [
          "application/xml"
        ],
        "consumes": [
          "application/xml"
        ],
        "parameters": [
          {
            "schema": {},
            "description": " ",
            "name": "body",
            "required": true,
            "in": "body"
          }
        ],
        "responses": {}
      }
    }
@MikeRalphson
Copy link
Member

What errors are you getting? Your example is a mix of v2.0 and v3.0.0 syntaxes. Both produces/consumes and in:body parameters have been removed.

@jeevarajan
Copy link
Author

yes, i didnt update any other syntax from v2.0. I will update once i understand the path specific URL.

I didnt get any errors, but still seeing the default url.

I want https://x.x.x.x/user, not https://x.x.x.x/user-enableuser

"openapi": "3.0.0",
....
"servers": [{
"url": "https://x.x.x.x"
}
],
......
"paths": {
"/user-enableuser": {
"post": {
"servers": [{
"url": "https://x.x.x.x/user"
}],
"tags": [
"user"
],

@MikeRalphson
Copy link
Member

Sorry, I should also have asked which tooling are you using? Perhaps it doesn't support servers at the path or operation level yet?

@jeevarajan
Copy link
Author

am trying this use case in swagger-ui-master.
I referred section "Overriding Servers" in https://swagger.io/docs/specification/api-host-and-base-path/

@MikeRalphson
Copy link
Member

If you check this issue on the swagger-ui repository - you can see that this functionality is still in the backlog of work to be done:

 Path and operation-level servers are not displayed

Use a UI similar to the top-level servers.
Implement functionality for Try-It-Out simultaneously.

If you need further information, you should raise an issue on the repository for the tooling concerned, not the specification itself.

@jeevarajan
Copy link
Author

What i am trying is, i want to send
curl -X POST https://x.x.x.x/user
for both the resources from the below given example

"paths": {
"/user-enableuser": {
..
},
"/user-disableuser":{
..
}

@MikeRalphson
Copy link
Member

The path is always appended to the servers values which are in context. Switching servers is not a great solution to having more than one POST operation per path.

An alternative (unless you are documenting an existing API) might be to have a toggleUser operation, which is passed a property or object containing the state to set the user to?

When swagger-ui supports multi-level servers it will be easier for you to visualise how various approaches will work for you.

@jeevarajan
Copy link
Author

But i am documenting existing API which is having more than one POST operation per PATH :(
Any luck?

@MikeRalphson
Copy link
Member

I think your best bet is to describe the requestBody as oneOf an array of schemas, as presumably the server disambiguates the operation required based on the content of the body, or some query or header parameter?

Alternatively, you could use differing content-types for the requestBody.

There is also this proposal which is marked for possible future consideration.

@jeevarajan
Copy link
Author

Thanks a lot @MikeRalphson for the info. It is really helpful.

@kanai0618
Copy link

Hi @MikeRalphson , wanted to know one thing, i have url eg: /internal/abc/ and in UI swagger i want to show /abc only. how do i do that ? whats the best possible way to do this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants