Swagger multiple Schemas in one response
openapi: 3.0.0 info: version: '1.0' title: Receipt API description: the ultimate receipt API servers: # Added by API Auto Mocking Plugin - description: SwaggerHub API Auto Mocking url: https://virtserver.swaggerhub.com/d.martins/receipts/1.0 paths: /receipts/: post: tags: - Receipts requestBody: $ref: '#/components/requestBodies/Items' responses: 201: description: Created components: requestBodies: Items: content: 'application/json': schema: $ref: '#/components/schemas/Items' Merchant: content: 'application/json': schema: $ref: '#/components/schemas/Merchant' schemas: Items: type: object properties: product: type: integer example: Bananas product category: type: integer example: Healthy fruit ean: type: string example: 1234567891012 price: type: number example: 19,99€ discount: type: string example: 15% discount value: type: number example: 2,98€ Merchant: type: object properties: merchant id: type: number example: 12345 store id: type: string example: ABC123456789 cashier: type: string example: Max Muster Receipt_properties: type: object properties: Receipt id: type: string example: ABC123456789123456789 transaction date and time: type: string example: 2021-05-05T11:11:11.123Z format: date-time Hey everyone, i am new to coding and try to learn how to create an api by writing one that should transfer receipt data. i managed to create Schemas to have a nice overview of all values. However i only manage to get one schema into my Post response, whatever i try i just run into error which is quite frustrating. I am Happy for any help! attached is the code:1.2KViews0likes0CommentsGenerate OpenAPI json through command line
I would like to generate OpenAPI Json file from the .NET core web api through command line. It is pretty easy change if I use swagger nuget within the .net solution but I just wonder if it can be done using any command line tool as a part of Azure devops build pipeline without updating the code. Thanks517Views0likes0CommentsLarge Swagger file not loading up in Chrome browser
Hello Everyone. I have a pretty big swagger file (around 10MB). I have 5 operations under it. All the operations are under <1 MB however the last operation is around 7-8 MB. When we tried to load the spec using our local swagger library, all the operation loads up fine except the big one. It takes around minute or 2 to load up. This only happens in chrome browser. In other browsers it works fine and loads up within 4-5 seconds. Have any one encounter this issue before and have done anything to resolve this? Chrome version I am using:Version 89.0.4389.72How to pass the header application/json in Get method of swagger.json
Hey all i just want to integrate my flask rest api in swagger by using flask_swagger_ui I had already integrated few api but when i'm hitting the "Get" method api, i'm getting error "None type object" i am passing the id as parameter but it is expecting the data in the form of json Can anyone help me how to pass the headers i.e., application/json for Get method in swagger.json fileWhat does <*> symbol represent in json swagger?
I have a question in JSON swagger. May I know what does <*> symbol represent in JSON swagger? This is how the format looks like after I import the JSON swagger into the online editor. What does <*> actually mean? CrossCurrencyRequest{ items* { < * >: CurrencyPairRequest{ amount* number currencyPair* string decimalPlace integer($int32) } } } Below are the definitions from the swagger file. definitions: CrossCurrencyRequest: type: object required: - items properties: items: type: object additionalProperties: $ref: '#/definitions/CurrencyPairRequest' title: CrossCurrencyRequest I have the sample request as given below. How to make the request generates the "key1", "key2", etc? As it seems like not a predefined object from the swagger file. Sample request: { "items": { "key1": { "amount": 1000.123456789, "currencyPair": "USD-SGD", "decimalPlace": 5 }, "key2": { "amount": 1000.12345, "currencyPair": "USD-IDR" }, "key3": { "amount": 1000.12345, "currencyPair": "USD-ZNH" } } }SolvedDoes OAS3 callbacks also relate about the Service implementation part ?
Does OAS3 callbacks also relate about the Service implementation part, because if at all this callback endpoint might be a part of different Swagger as well ? Lets say I have OAS3 based Swagger101.json that has a subscription endpoint operation which is configured with a callbacks operation for callbacks URL. So does the callbacks definition for this mean that the callbacks URL belongs to some other Service Swagger spec or basically another Swagger JSON. There might be a possibility that this callbacks endpoint operation might be part of whole different Swagger spec that has a lot of operations and endpoints to offer. Does this make sense ?OAuth2.0 Client Credentials Parameters
Hi Team, I'm fairly new to Swagger Editor and API documentation and I have to add a parameter to pass my access token in the API documentation.I am using OAuth 2.0 with Grant Type- Client Credentials. I am able to lock the APIs using the Authorize button on my Swagger's interactive UI but I need to view the generated access token on my interactive UI.and send it as a header parameter to specific APIs. This is the security component I have added to my document: components: securitySchemes: oAuth2ClientCredentials: type: oauth2 flows: clientCredentials: tokenUrl: 'https://localhost:8081/oauth/token' scopes: {} Thanks in advance!SolvedHow can response status code make sense for multiple media types for error status codes
If we follow the OAS3 spec for Response herewe can see that each response status code can have multiple media types and each media type inturn has a schema particular to it. For example below, we can see 200 has a binary stream response but 400 has 2 media-types:application/json, application/xml. So is client expected to request accept-type header with all the media-types mentioned below. How can we have specific media-type for 400 response code, or basically how we can convey to the REST Service to respond with media type as application/xml when its a 400 bad request if 200 is returning a binary stream. Does this OAS3 response multiple media-type make sense for Client/Server Errors. If yes then whats the accept-type set for expecting, say "application/xml" for 400 bad request '200': description: Document content from the Archive content: application/octet-stream: schema: type: string format: binary '400': description: One or more input parameters are invalid content: application/json: schema: type: "object" properties: errors: $ref: "#/components/schemas/Error_400" application/xml: schema: type: "object" properties: errors: $ref: "#/components/schemas/Error_400" '403': description: Consumer doesn't have access to the document content: application/xml: schema: type: "object" properties: errors: $ref: "#/components/schemas/Error_403"Java JAXB generated classes and swagger
I have JAXB generated classes @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "MyResponse", propOrder = { "member1", "member2", "member3" }) public class MyResponse implements Serializable { <... other class members; setters/ getters ...> } @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "myRequest", propOrder = { "test1", "test2", "test3" }) public class MyRequest implements Serializable { <... other class members; setters/ getters ...> } However, swagger 2 (version 3.0.0) generates example values as <?xml version="1.0" encoding="UTF-8"?> <JAXBElement«MyRequest»> <name> <localPart>jhgkhgk</localPart> <namespaceURI>gfjgfj</namespaceURI> <prefix>gfjhgfj</prefix> </name> <nil>true</nil> <MyRequest> <test1>string</test1> <test2>string</test2> <test3>string</test3> </MyRequest> </JAXBElement«MyRequest»> How to force swagger to generate example values of <MyRequest> <test1>string</test1> <test2>string</test2> <test3>string</test3> </MyRequest> My Controller class public @ResponseBody JAXBElement<MyRequest> test( @RequestBody JAXBElement<MyResponse> message) { }596Views0likes0CommentsYaml working on editor but converted json has warnings on codegen build and fails to run
Good afternoon, I have written the yaml file for my project in the editor and converted it to json to have it generated using the swagger codegen tool.The steps I took worked for a previous iteration to this project but after adding ~1000 lines to the file something seems to have gone wrong. Below are the steps I took and the output I recieved. Generating the code started with this command java -jar swagger-codegen-cli-3.0.23.jar generate -i /home/swagger_projects/openapi.json -l python-flask -o FlaskConnexion-python2 -D supportPython2=true which spits out a bunch of this warning 15:59:37.278 [Thread-0] WARN i.s.c.v.g.DefaultCodegenConfig - String to be sanitized is null. Default to Object It finishes generating and then when I install the requirements and go to run the server I end up with the following error main__.py", line 5, in <module> from swagger_server import encoder File "swagger_server/encoder.py", line 4, in <module> from swagger_server.models.base_model_ import Model File "swagger_server/models/__init__.py", line 10, in <module> from swagger_server.models.body import Body File "swagger_server/models/body.py", line 9, in <module> from swagger_server.models.data import Data # noqa: F401,E501 File "swagger_server/models/data.py", line 9, in <module> from swagger_server.models.object import Object # noqa: F401,E501 ImportError: No module named object I assume that this error has something to do with the null strings defaulting to Objects, but I cannot find any more info on what that warning means. If anyone has any Idea on either how to fix the warnings or the error it would be greatly appreciated! I unfortunately cannot share the json as it is for my work project, but if anyone recognizes what type of behavior or patterns would cause these issues it would be extremely useful as well. Thank you!