Coder Social home page Coder Social logo

spring-cloud-contract-oa3's Issues

Maven Central

Are you planning to push your releases to maven central?

Implement mulitpart support

Acceptance Criteria:

  1. Multipart can be defined in oa3 with contracts definitions like client and server part.
  2. There are tests which validates fully all fields which can be used with multipart

path parameter in OA3 spec gets converted to query parameter in generated tests

I'm using the spring-cloud-contract-oa3 v3.1.1.0 and it converts the path param of my endpoint as a query param in the generated tests. Am I specifying the contract wrong or is there a bug in spring-cloud-contract-oa3?

Here is an example of an OA3 yaml with path param:

openapi: 3.0.3
    info:
      title: Doughnuts
      version: 0.0.1
      description: |-
        API to make doughnuts
    servers:
      - url: 'http://localhost:8080/'
        description: Local
    paths:
      '/doughnuts/{doughnutId}':
        parameters:
          - schema:
              type: string
              example: PEANUT_BUTTER
            name: doughnutId
            in: path
            required: true
            description: Use doughnut to fetch details
            x-contracts:
              - contractId: 1
                value: PEANUT_BUTTER
        get:
          summary: Get doughnut by doughnut Id
          x-contracts:
            - contractId: 1
              name: Should return doughnut by id
          responses:
            '200':
              description: Ok
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/DoughnutDto'
              x-contracts:
                - contractId: 1
                  body:
                    doughnutId: "PEANUT_BUTTER"
                    cost: 1.99
                  headers:
                    Content-Type: application/json
                    
    components:
      schemas:
        DoughnutDto:
          title: DoughnutDto
          type: object
          description: Doughnut data
          properties:
            doughnutId:
              type: string
              example: PEANUT_BUTTER
              description: Doughnutu Identifier
            cost:
              type: number
              description: doughnut cost
              example: 1.99
          required:
            - doughnutId
            - cost

Here is the generated test:

     @Test
  public void validate_should_return_doughnut_by_id() throws Exception {
	  // given:
		  MockMvcRequestSpecification request = given();


	  // when:
		  ResponseOptions response = given().spec(request)
				  .queryParam("doughnutId","PEANUT_BUTTER")
				  .get("/doughnuts/{doughnutId}");

	  // then:
		  assertThat(response.statusCode()).isEqualTo(200);
		  assertThat(response.header("Content-Type")).isEqualTo("application/json");


	  // and:
		  DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
		  assertThatJson(parsedJson).field("['doughnutId']").isEqualTo("PEANUT_BUTTER");
		  assertThatJson(parsedJson).field("['cost']").isEqualTo(1.99);
  }

Add sonar plugin

Acceptance Criteria:

  • sonar checks code
  • status is displayed in README.md

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.