Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for yaml files #34

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Criteo.OpenApi.Comparator.UTest/OpenApiParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Reflection;
using Criteo.OpenApi.Comparator.Parser;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Microsoft.OpenApi.Readers.Exceptions;
using NUnit.Framework;

namespace Criteo.OpenApi.Comparator.UTest
Expand All @@ -29,16 +29,16 @@ public void OpenApiParser_Should_Throw_Exception_When_Invalid_Json()
{
const string fileName = "invalid_json_file.txt";
var documentAsString = ReadOpenApiFile(fileName);
Assert.Throws<JsonReaderException>(() => OpenApiParser.Parse(documentAsString));
Assert.Throws<OpenApiUnsupportedSpecVersionException>(() => OpenApiParser.Parse(documentAsString));
}

/// <summary>
/// Verifies that a valid JsonDocument object is parsed when input is a valid OpenApi
/// </summary>
[Test]
public void OpenApiParser_Should_Return_Valid_OpenApi_Document_Object()
[TestCase("openapi_specification.json")]
[TestCase("openapi_specification.yaml")]
public void OpenApiParser_Should_Return_Valid_OpenApi_Document_Object(string fileName)
{
const string fileName = "openapi_specification.json";
var documentAsString = ReadOpenApiFile(fileName);
var validOpenApiDocument = OpenApiParser.Parse(documentAsString);
Assert.IsInstanceOf<JsonDocument<OpenApiDocument>>(validOpenApiDocument);
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
openapi: 3.0
info:
title: removed_definition
version: "2.0"
servers:
- url: http://localhost:8000
paths:
/api/Parameters:
get:
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
type: object
discriminator:
propertyName: petType
properties:
name:
type: string
petType:
type: string
enum:
- cat
- dot
- bird
additionalProperties:
type: string
required:
- name
- petType
108 changes: 0 additions & 108 deletions src/Criteo.OpenApi.Comparator.UTest/Resource/new/added_enum_value.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
openapi: 3.0
info:
title: removed_definition
version: "2.0"
servers:
- url: http://localhost:8000
- url: https://localhost:8000
paths:
/api/Parameters:
put:
tags:
- Parameters
operationId: Parameters_Put
parameters:
- $ref: '#/components/parameters/skipParam'
- $ref: '#/components/parameters/limitParam'
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
type: object
discriminator:
propertyName: petType
properties:
name:
type: string
petType:
type: string
enum:
- cat
- dot
- bird
accountType:
type: string
enum:
- Standard_LRS
- Standard_ZRS
- Standard_GRS
- Standard_RAGRS
- Premium_LRS
x-ms-enum:
name: AccountType
modelAsString: true
required:
- name
- petType
parameters:
skipParam:
name: skipParam
in: query
description: number of items to skip
required: true
schema:
type: integer
format: int32
limitParam:
name: limitParam
in: query
description: max records to return
required: true
schema:
type: string
enum:
- clueless
- adventurous
44 changes: 0 additions & 44 deletions src/Criteo.OpenApi.Comparator.UTest/Resource/new/added_header.json

This file was deleted.

27 changes: 27 additions & 0 deletions src/Criteo.OpenApi.Comparator.UTest/Resource/new/added_header.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: 3.0.1
info:
title: operation_check_03
version: "2.0"
paths:
/api/Parameters:
get:
operationId: Responses_Get
responses:
"200":
description: dummy response
content:
application/json:
schema:
type: integer
headers:
x-d: {}
/api/Responses:
get:
operationId: Responses_Get
responses:
"200":
description: null
headers:
x-a: {}
x-b: {}
x-c: {}
Loading
Loading