Adding example in parameters not showing up in Swagger UI
Trying to add example in parameter but its not showing up in Swagger UI. parameters: - in: query name: tpaaId description: third party plan Identifier from HDM. Example:`9740000` required: true schema: type: string example: 111 Configs in pom.xml is below, <java.version>11</java.version> <spring-cloud.version>2021.0.1</spring-cloud.version> <spring-cloud-gcp.version>2.0.4</spring-cloud-gcp.version> <mapstruct.version>1.4.2.Final</mapstruct.version> <openapi-version>1.2.32</openapi-version> <springdoc-openapi-webflux-ui-version>1.6.12</springdoc-openapi-webflux-ui-version> <swagger-annotations-version>1.6.9</swagger-annotations-version> <springfox-swagger2>3.0.0</springfox-swagger2> <jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version> <karate.version>0.9.6</karate.version> <openapi-tool-version>5.4.0</openapi-tool-version>1.1KViews0likes0CommentsSwagger OpenAPI3 POST Array of images and media file together
I am using the swagger python-flask framework to create an OpenAPI 3 API which needs to do the following: 1. Upload a video file 2. Upload an array of images 3. Upload extra string data. I can successfully upload a single file successfully using: MyFileUploadAPI: post: operationId: my_file_upload requestBody: content: multipart/form-data: schema: $ref: '#/components/schemas/videofile' components: schemas: videofile: type: object properties: upload: type: string format: binary # This works fine def my_file_upload(videofile): file_name = videofile.filename And I can upload an array of images and other data using: MyMultipleImagesUploadAPI: post: operationId: multiple_files requestBody: content: application/json: schema: $ref: '#/components/schemas/multiplefiles' components: schemas: multiplefiles: type: object properties: Images: items: $ref: '#/components/schemas/MyImage' TotalCount: type: integer # This works fine def multiple_files(body): if connexion.request.is_json: body = multiplefiles.from_dict(connexion.request.get_json()) images = body._images count = body._totalcount Now I wish to combine the two together (Video upload + Multiple images + extra data) So I have did the following: /MyEverythingAPI: post: operationId: video_multiple_images requestBody: content: multipart/form-data: schema: $ref: '#/components/schemas/everything' components: schemas: everything: type: object properties: Video: type: string format: binary Images: type: array items: $ref: '#/components/schemas/MyImage' TotalCount: type: integer # This has issues def video_multiple_images(body, video_clip, **kwargs): #body = {'images': ['[object File]'], 'totalcount': 2} uploaded_file_name = video_clip.filename Now there are 2 issues that I see that are just not correct: Issue 1. The video_clip was not getting passed through to the function video_multiple_images. I debugged and tracked it down and saw that it was not getting added because there were no **kwargs added to my function signature. When I added the**kwargs then the video file started to get passed through. This post helped me solve that part: https://github.com/zalando/connexion/pull/753/files I can live with this issue but would like to know why this is the case. Issue 2. The image array is coming through as [object File]''[Object File]'' etc. This post indicates that this is not supported in OpenAPI 3: In Swagger openapi v3.0.0, facing issue in multiple file uploads So how can I pass a video file + an array of images?1.4KViews0likes0Commentshow to have different required fields for the create (put) and update api?
I have a schema defined say star which has name as required field.But i want this field to be required in create body request but not in update body request. What is the correct way to do without redundant code? Star: title: Star description: star found required: - name properties: id: description: the id for the star type: string format: uuid4 readOnly: true x-go-name: ID name: description: name of the star type: string x-go-name: StarHow to document resource at base path of application
Hello , i have java project using resteasy services and basic swagger config via application class. When i access openapi.json file at my applicaiton url its seem swagger skip to document the method which is on root path "/". I have this problem when the base path is "/". My generated json file is bellow with the dependancy i use and sample code: I ll be glad if somoene help! @ApplicationPath("/") public class Application extends javax.ws.rs.core.Application { @Override public Set<Class<?>> getClasses() { return Stream.of(PersonService.class, OpenApiResource.class, AcceptHeaderOpenApiResource.class) .collect(Collectors.toSet()); } } @Path("/") @OpenAPIDefinition( tags = { @Tag (name = "persons") } ,info = @Info (title = "Person API",version = "1.0.0") ,servers = @Server(url = "/")) public class PersonService { @GET @Path("/person") @Produces(MediaType.APPLICATION_JSON) public Person getPerson() { return new Person("1","person"); } @GET @Produces(MediaType.APPLICATION_JSON) public Person getPersonById(@PathParam("petId") String id) { return new Person("2","person2"); } } { "openapi" : "3.0.1", "info" : { "title" : "Person API", "version" : "1.0.0" }, "tags" : [ { "name" : "persons" } ], "paths" : { "/person" : { "get" : { "operationId" : "getPerson", "responses" : { "default" : { "description" : "default response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Person" } } } } } } } }, "components" : { "schemas" : { "Person" : { "type" : "object", "properties" : { "id" : { "type" : "string" }, "name" : { "type" : "string" } } } } } } <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-jaxrs2</artifactId> <version>2.0.8</version> </dependency>Getting Information like Parameters/Payload of a service from its Swagger definition (via API ?)
Hi Guys, I'm new to Swagger and wanted to ask you some questions. I hope you can help. Im planing on building a tool that can test Services via APIs by generating the needed API call with Payload and setting all parameters in a GUI. All services are or will be documented in/with (not sure whats the right saying) swagger. So I wanted to ask if theres the possibility to get all implemented parameters (Payload/Path/Query) for the in swagger documented API from swagger directly. (Like with an API of swagger). I hope you understand. I want to implement that my tool knows dynamiclly from the swagger definition which parameters are mandatory/possible for the specific service the user want to test. In my imagination the user choses a service and the tool calls an API of swagger to the documented service and swagger will return all needed parameters/objects/.. So I dont have to hard code the implementation of a service..Instead its always up to date! Thank you in advance! Greeting Ben aka LordeKSwagger UI,doesn't give correct object request and response as a example value.
Hiiii, I have implemented swagger UI in my application. Everything is working fine but the issue is, consider the situation in my API I have different request and response object, but both object's class is annotated with the same json root element name (Ex: @JsonRootName("user")). For this reason in my swagger UI it gives me same example value in Parameters body and in Responses body. If i remove this @JsonRootName tag from any one class than swagger UI shows me correct example value, but for my application i can't remove this annotation from any class and even can't change the value of it. I tried many option available on internet but can't resolve my problem. Please help me to resolve this. Please refer the attached screens. I have find the issue but didn't get solution on it ,it related to jackson who always picks the Jackson lib annotation name (@JsonRootname()),if JsonRootname value name is duplicate in req and resp object then it is overriding the one the object and display same object in req and resp object example value, instead it should take the model class name. Thanks, Waiting for your response2.7KViews0likes0CommentsHow to generate the same Bearer token as Swagger?
I have given an API which uses Basic_auth for Authentication. it requires 'username', 'password', (type:basic_auth), 'ClientId' and 'secret'. I use the Swagger UI to authenticate and it works perfectly fine: the Curl will look like this: curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1ZR0FtX2hHeWRvYWhrSGtlcjRlaTRiTXRSUSIsImtpZCI6Ik1ZR0FtX2hHeWRvYWhrSGtlcjRlaTRiTXRSUSJ9.eyJpc3MiOiJDdXN0b21lckNsdWJXZWJTZXJ2aWNlIiwiYXVkIjoiQ3VzdG9tZXJDbHViV2ViU2VydmljZS9yZXNvdXJjZXMiLCJleHAiOjE1NjM4NzY2MTEsIm5iZiI6MTU2MzI3MTgxMSwiY2xpZW50X2lkIjoiY3VzdG9tZXJjbHViIiwic2NvcGUiOlsib3BlbmlkIiwicHJvZmlsZSIsInVzZXJfaW5mbyJdLCJzdWIiOiJjdXN0b21lcmNsdWIiLCJhdXRoX3RpbWUiOjE1NjMyNzE4MTEsImlkcCI6Imlkc3J2IiwicHJpbWFyeV9zaWQiOiJjdXN0b21lcmNsdWIiLCJ1cG4iOiJjdXN0b21lcmNsdWIiLCJuYW1lIjoiY3VzdG9tZXJjbHViIiwiZ2l2ZW5fbmFtZSI6ImN1c3RvbWVyY2x1YiIsImp0aSI6IjRhMGUyZjNkYjUzYjY2ZGQxMDIwMmJkNmVmNzM4OWJjIiwiYW1yIjpbImN1c3RvbSJdfQ.YY1CzHzWPK_E1S7y8TDrwRT0orCS9zfN-4n5pTC1zYMomkOkJOdpvmSZyrabirBeLpGi870T9H-z9ufkYX5B1bPZlQlQRAAaDPeq_pV7Gls9EPLhAK8uXK4i5jaF1aNN5hiBP6fAJZxhZnHsmUevXs6y5s9FJeVZ1vPpDfJ69d3rrTvte_2A6hEE6fpkYeZGUKRS8eTaWHSrdZh9-18FaQN4VGbCCtsHR7x-A2HMLIG8q9MWp6iu_KDJ95wOHO_tp--AER4CoGta0HrleI7CNUBz43TN-kEklmzVCODuFA7varUIAiee4Zd2PKG7MlGEdkOBA5qwoX1HhsobGOI5ZA' ' The problem is, every time the token expires, I have to come back and use the Swagger UI to authenticate, and copy the Bearer token to my app. I would like to know, how Swagger is creating it? And how could I implement it on my machine so that everytime it expires, my app creates it itself instead of getting an error and changing it? I tried many ways, but I couldn't get the Bearer token the way Swagger gets it. It only works when Swagger creates it.5.7KViews0likes2Comments