In swaager-doc,i want to add a header param for all api .This param is for filter to search some information and is must required.
Any Suggestion for it.
I'm trying to put in swagger for documentation the link below.
https://server.dc.ege.ds:50001/XMII/Runner?Transaction=SC_AUTOMATION/API/SCRAP_LIST/SCRAP_LIST&OutputParameter=ResultXML&Plant=1345&Plant=1345&BookingdateFrom=2022-08-31T10%3A57%3A44
I see a particulariry of having my endpoint "/Runner?" followed by "Transaction=SC_AUTOMATION/API/SCRAP_LIST/SCRAP_LIST" I don't know ho to explicit it in swagger.
OutputParameter=ResultXML is currently a parameter but in fact there is no other possibily than "ResulXML" any possibility to define it as fixed ?
thanks a lot for your reading
I set up a basic JHipster project and generated an entity that supports filtering with JDL.
The generator made a Swagger API which I use for querying the database.
The Swagger API doc shows me a list of parameters which can be used to build query.
The template query looks like this:
GET /api/client?name.equals=john&surname.equals=doe&country.in=uk&country.in=de
The request works fine but the parameters are chained like name==john OR surname==doe OR country==uk OR country==de so I get all johns, does, and everoyne from uk and de.
This is ok, but for some queries i need name==john AND surname==doe so not all Johns and Does but specifically John Doe. I searched here and on the swagger forum but couldn't find the answer.
My question is: how do I achieve changing the OR to AND in the query?
Does this swagger query support AND or do I have to make changes in the backend?
Your question is not about swagger, this is why you could not find anything in swagger forum.
It's about JHipster JPA entity filtering and the answer is no: you can't generate code that would use a OR.
You must code it yourself, look at the *QueryService classes and assemble your criteria with the logic you need.
I'm importing a swagger specification file into postman to create a collection, at this point, works as expected and the collection is generated with all requests & sub-folders, fine!!. But when the api is updated, I need update the postman to update all requests based on the new specification. I can't find a action like "update" or something else. I'm trying import the new specification into postman and he say:
A collection APIName already exists.
What would you like to do?
Replace or Import as copy
a copy its a not feasible option, then I use replace and the existent collection is updated, but all tests, parameters, pre-req scripts are remove and I need reconfigure all again.
I'm missing something, exist a way to import & update a existent collection from a specification file, without losing existent tests & configuration?
thanks in advance!
Postman does not support this as of now. Link
Alternative I learned from this blog. In short:
Update your OpenAPI YAML/JSON files.
Import to Postman as a new collection.
Export the new collection from Postman. As JSON in Collection v2.1 format (recommended).
Using Postman API (Update Collection), update the existing collection with the JSON in step 3 as body. Make sure to update collection_uid accordingly.
Postman update collection API body sample:
{
"collection":
<------- YOUR EXPORTED COLLECTION HERE --------->
}
I have made a small tool to do this: swagger2postman: convert swagger to postman collection and update exist collection
The tool will combine new and old collection, when conflict, it will use saved in postman. The tool can detect update in query parameter, but not post body. It will keep all your collection and test cases.
There is no straightforward solution. There also probably won't be one for quite some time - the devs said it is hard to correlate old Postman requests in a collection with new requests generated from incoming Swagger file (or any other source of updates, for that matter).
You can do it outside of Postman, though. Postman collections are really just JSON data and can be manipulated as such.
Transform your Swagger file to a Postman collection file. (You can just import it and export it again, or use tools like Swagger2Postman if you want to automate. Save it as collection 2.0 or newer, that format makes step 3 a lot easier.)
Export your old collection in the same version
Merge the two JSONs in your preferred scripting language
Import the merged JSON back to Postman
I made myself a simple helper for step 3. It is fine if you are just adding more stuff to the collection (my case), but can't remove anything. If anyone has a more versatile solution, please, post it - I would gladly use it instead.
function execute() {
collection = JSON.parse($(".collection").val());
swagger = JSON.parse($(".swagger").val());
result = JSON.stringify($.extend(true, {}, swagger, collection));
$(".result").val(result);
}
<html><body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<br>Collection: <br> <textarea class="collection"></textarea>
<br>Swagger: <br> <textarea class="swagger"></textarea>
<br>Result: <br> <textarea class="result"></textarea>
<br>
<button onClick="execute()">EXECUTE</button>
</body></html>
It seems that they have implemented this feature,
https://github.com/postmanlabs/postman-app-support/issues/6722#issuecomment-652929581
https://learning.postman.com/docs/designing-and-developing-your-api/validating-elements-against-schema/
You can paste your new schema in the API define tab and update it.
I am currently working on Azure API App services, In that I have little bit confusion for generating swagger metadata using swashbuckler. for that I read the below documentation in that they are mentioning to see your metadata just add swagger/docs/v1 at the end your API url.
https://learn.microsoft.com/en-us/azure/app-service-api/app-service-api-dotnet-get-started
I am also did same thing and I am able to see my metadata generation In the form JSON. but when I added swagger/help/v1 or swagger/help/v2 at the end of my API url, I am not getting any metadata in the form JSON.
Is there any reason using only swagger/docs/v1 for generating swagger metadata in the form JSON or others also allowed like swagger/help/v1 etc.
Swashbuckle's default path is /swagger/docs/v1, and the Swashbuckle docs show how to change that path.
httpConfiguration
.EnableSwagger("docs/help/{apiVersion}", c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi("sandbox/{*assetPath}");
In this case the URL to swagger json will be docs/help/v1 and the url to the swagger-ui will be sandbox/index.