Giter Site home page Giter Site logo

Comments (4)

czechboy0 avatar czechboy0 commented on June 5, 2024 1

Depends on what you mean by "invalid". If you mean malformed JSON, then the answer is no (unless you write a middleware that malforms the outgoing requests, I guess that'd work). If you mean that e.g. the server expects a string with a certain prefix and that prefix is missing, then yes, but that's purely application-logic semantics.

If you want to test how your server is performing fully integrated, maybe use something like XCTVapor (if you're using Vapor) or whatever web framework you use. That should allow you to send completely arbitrary requests and verify that your server behaves as expected.

from swift-openapi-generator.

mapedd avatar mapedd commented on June 5, 2024 1

unless you write a middleware that malforms the outgoing requests

seems to be this could work and would be the easiest , thanks!

maybe use something like XCTVapor (i
Of course there are thousands other possibilities to do that, my goal is to write as little code apart from code generated as possible

Thanks for help

from swift-openapi-generator.

czechboy0 avatar czechboy0 commented on June 5, 2024

If you want to test your server implementation (the type that conforms to APIProtocol), you can write tests like this: https://github.com/apple/swift-openapi-generator/blob/main/Examples/hello-world-vapor-server-example/Tests/HelloWorldVaporServerTests/HelloWorldVaporServerTests.swift

While the example is specific to Vapor, notice that the test itself is web framework-agnostic, the file doesn't even import Vapor.

from swift-openapi-generator.

mapedd avatar mapedd commented on June 5, 2024

My goal to write a integration test (not a unit test that just calls methods without real network) that sends actual network request, and I'm just wondering, if it's possible to send invalid data using the client code generated by the Swift Code gen?

from swift-openapi-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.