Skip to content

Commit

Permalink
fix(edulint): new api format
Browse files Browse the repository at this point in the history
  • Loading branch information
esoadamo committed Aug 29, 2024
1 parent 790a4ae commit d5eacaa
Show file tree
Hide file tree
Showing 19 changed files with 352 additions and 54 deletions.
100 changes: 86 additions & 14 deletions src/api/edulint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ info:
# license:
# name: Apache 2.0
# url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
version: 1.0.1
# externalDocs:
# description: Find out more about Swagger
# url: http://swagger.io
servers:
- url: ""
- url: "https://edulint.com"
- url: "https://dev.edulint.com"
tags:
- name: API
description: ""
Expand All @@ -33,6 +34,26 @@ tags:
# description: Find out more about our store
# url: http://swagger.io
paths:
/api/:
get:
summary: This API documentation.
responses:
"200":
description: ""
/api/versions:
get:
summary: List of currently supported Edulint versions.
responses:
"200":
description: The versions are sorted -- the newest version is listed first.
content:
application/json:
schema:
type: array
items:
type: string
example: ["2.10.2", "2.9.2"]

/api/code:
post:
tags:
Expand All @@ -41,11 +62,11 @@ paths:
# description: Update an existing pet by Id
# operationId: updatePet
requestBody:
description: the code to upload
description: information on the code to upload
content:
application/json:
schema:
$ref: "#/components/schemas/Code"
$ref: "#/components/schemas/CodeRequest"
# application/xml:
# schema:
# $ref: "#/components/schemas/Pet"
Expand All @@ -63,6 +84,8 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Hash"
"400":
description: Missing parameter with uploaded code
# security:
# - petstore_auth:
# - write:pets
Expand Down Expand Up @@ -105,24 +128,36 @@ paths:
parameters:
- name: version
in: path
description: the version of EduLint to use
description: The version of EduLint to use. You can use either a specific version (e.g. 2.0.0) or "latest".
required: true
schema:
type: string
example: 2.0.0
example: latest
- name: hash
in: path
description: the hash of the code to analyze
required: true
schema:
$ref: "#/components/schemas/HashStr"
- name: config
in: query
description: extra configuration to use (equivalent to command line configuration described in [EduLint's documentation](https://edulint.rtfd.io#configuration)).
required: false
schema:
$ref: "#/components/schemas/QueryConfig"
- name: use-cached-result
in: query
description: enables/disables using cached linting results
required: false
schema:
$ref: "#/components/schemas/TrueBoolean"
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Problems"
$ref: "#/components/schemas/AnalyzeResponse"
"400":
description: Invalid hash supplied
"404":
Expand All @@ -136,25 +171,37 @@ paths:
parameters:
- name: version
in: path
description: the version of EduLint to use
description: The version of EduLint to use. You can use either a specific version (e.g. 2.0.0) or "latest".
required: true
schema:
type: string
example: 2.0.0
example: latest
- name: config
in: query
description: extra configuration to use (equivalent to command line configuration described in [EduLint's documentation](https://edulint.rtfd.io#configuration)).
required: false
schema:
$ref: "#/components/schemas/QueryConfig"
- name: use-cached-result
in: query
description: enables/disables using cached linting results
required: false
schema:
$ref: "#/components/schemas/TrueBoolean"
requestBody:
description: the code to upload and analyze
content:
application/json:
schema:
$ref: "#/components/schemas/Code"
$ref: "#/components/schemas/CodeRequest"
required: true
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Problems"
$ref: "#/components/schemas/AnalyzeResponse"
"400":
description: Invalid hash supplied
"404":
Expand All @@ -177,19 +224,23 @@ paths:

components:
schemas:
Code:
CodeRequest:
type: object
properties:
code:
type: string
example: print('Hello world')
source_id:
type: string
example: ksi:task_99:user_aa554ae56217f
required: [code]
CodeFile:
type: string
format: binary
example: print('Hello world')
HashStr:
type: string
example: c4bc51f7d34f9340c33e0b3b9dcfd12aa8917fe5a11faa5f6385f5bb41be9fcf
example: a10b77b1feed3225cceb4b765068965ea482abfc618eee849259f7d1401cd09d
Hash:
type: object
properties:
Expand All @@ -200,7 +251,7 @@ components:
properties:
path:
type: string
example: codes/c4bc51f7d34f9340c33e0b3b9dcfd12aa8917fe5a11faa5f6385f5bb41be9fcf.py
example: codes/a10b77b1feed3225cceb4b765068965ea482abfc618eee849259f7d1401cd09d.py
source:
type: string
example: pylint
Expand Down Expand Up @@ -232,3 +283,24 @@ components:
type: array
items:
$ref: "#/components/schemas/Problem"
ConfigError:
type: string
example: unrecognized option foo
AnalyzeResponse:
type: object
properties:
problems:
$ref: "#/components/schemas/Problems"
config_errors:
type: array
items:
$ref: "#/components/schemas/ConfigError"
hash:
$ref: "#/components/schemas/HashStr"
QueryConfig:
type: string
example: config-file=cs0
TrueBoolean:
type: boolean
enum: [true, false]
default: true
2 changes: 2 additions & 0 deletions src/api/edulint/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HttpClient } from '@angular/common/http';


import { APIService } from './api/aPI.service';
import { DefaultService } from './api/default.service';
import { WebService } from './api/web.service';

@NgModule({
Expand All @@ -12,6 +13,7 @@ import { WebService } from './api/web.service';
exports: [],
providers: [
APIService,
DefaultService,
WebService ]
})
export class ApiModule {
Expand Down
70 changes: 49 additions & 21 deletions src/api/edulint/api/aPI.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EduLint web API
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: 1.0.0
* OpenAPI spec version: 1.0.1
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
Expand All @@ -17,11 +17,13 @@ import { CustomHttpUrlEncodingCodec } from '../encoder';

import { Observable } from 'rxjs';

import { Code } from '../model/code';
import { AnalyzeResponse } from '../model/analyzeResponse';
import { CodeFile } from '../model/codeFile';
import { CodeRequest } from '../model/codeRequest';
import { Hash } from '../model/hash';
import { HashStr } from '../model/hashStr';
import { Problems } from '../model/problems';
import { QueryConfig } from '../model/queryConfig';
import { TrueBoolean } from '../model/trueBoolean';

import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
Expand All @@ -30,7 +32,7 @@ import { Configuration } from '../configurat
@Injectable()
export class APIService {

protected basePath = '';
protected basePath = 'https://edulint.com';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();

Expand Down Expand Up @@ -62,15 +64,17 @@ export class APIService {
/**
* Analyzes the code with the given hash with the given version of EduLint
*
* @param version the version of EduLint to use
* @param version The version of EduLint to use. You can use either a specific version (e.g. 2.0.0) or \"latest\".
* @param hash the hash of the code to analyze
* @param config extra configuration to use (equivalent to command line configuration described in [EduLint's documentation](https://edulint.rtfd.io#configuration)).
* @param use_cached_result enables/disables using cached linting results
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public analyzeUploaded(version: string, hash: HashStr, observe?: 'body', reportProgress?: boolean): Observable<Problems>;
public analyzeUploaded(version: string, hash: HashStr, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Problems>>;
public analyzeUploaded(version: string, hash: HashStr, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Problems>>;
public analyzeUploaded(version: string, hash: HashStr, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
public analyzeUploaded(version: string, hash: HashStr, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'body', reportProgress?: boolean): Observable<AnalyzeResponse>;
public analyzeUploaded(version: string, hash: HashStr, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<AnalyzeResponse>>;
public analyzeUploaded(version: string, hash: HashStr, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<AnalyzeResponse>>;
public analyzeUploaded(version: string, hash: HashStr, config?: QueryConfig, use_cached_result?: TrueBoolean, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {

if (version === null || version === undefined) {
throw new Error('Required parameter version was null or undefined when calling analyzeUploaded.');
Expand All @@ -80,6 +84,16 @@ export class APIService {
throw new Error('Required parameter hash was null or undefined when calling analyzeUploaded.');
}



let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
if (config !== undefined && config !== null) {
queryParameters = queryParameters.set('config', <any>config);
}
if (use_cached_result !== undefined && use_cached_result !== null) {
queryParameters = queryParameters.set('use-cached-result', <any>use_cached_result);
}

let headers = this.defaultHeaders;

// to determine the Accept header
Expand All @@ -95,8 +109,9 @@ export class APIService {
const consumes: string[] = [
];

return this.httpClient.request<Problems>('get',`${this.basePath}/api/${encodeURIComponent(String(version))}/analyze/${encodeURIComponent(String(hash))}`,
return this.httpClient.request<AnalyzeResponse>('get',`${this.basePath}/api/${encodeURIComponent(String(version))}/analyze/${encodeURIComponent(String(hash))}`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
Expand Down Expand Up @@ -149,14 +164,14 @@ export class APIService {
/**
* Uploads some code
*
* @param body the code to upload
* @param body information on the code to upload
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public apiCodePost(body: Code, observe?: 'body', reportProgress?: boolean): Observable<Hash>;
public apiCodePost(body: Code, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Hash>>;
public apiCodePost(body: Code, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Hash>>;
public apiCodePost(body: Code, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
public apiCodePost(body: CodeRequest, observe?: 'body', reportProgress?: boolean): Observable<Hash>;
public apiCodePost(body: CodeRequest, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Hash>>;
public apiCodePost(body: CodeRequest, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Hash>>;
public apiCodePost(body: CodeRequest, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {

if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling apiCodePost.');
Expand Down Expand Up @@ -197,14 +212,16 @@ export class APIService {
* Uploads some code and returns its analysis
* This endpoint combines the /code and /api/{version}/analyze/{hash} endpoints.
* @param body the code to upload and analyze
* @param version the version of EduLint to use
* @param version The version of EduLint to use. You can use either a specific version (e.g. 2.0.0) or \&quot;latest\&quot;.
* @param config extra configuration to use (equivalent to command line configuration described in [EduLint&#x27;s documentation](https://edulint.rtfd.io#configuration)).
* @param use_cached_result enables/disables using cached linting results
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public apiVersionAnalyzePost(body: Code, version: string, observe?: 'body', reportProgress?: boolean): Observable<Problems>;
public apiVersionAnalyzePost(body: Code, version: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<Problems>>;
public apiVersionAnalyzePost(body: Code, version: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<Problems>>;
public apiVersionAnalyzePost(body: Code, version: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
public apiVersionAnalyzePost(body: CodeRequest, version: string, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'body', reportProgress?: boolean): Observable<AnalyzeResponse>;
public apiVersionAnalyzePost(body: CodeRequest, version: string, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<AnalyzeResponse>>;
public apiVersionAnalyzePost(body: CodeRequest, version: string, config?: QueryConfig, use_cached_result?: TrueBoolean, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<AnalyzeResponse>>;
public apiVersionAnalyzePost(body: CodeRequest, version: string, config?: QueryConfig, use_cached_result?: TrueBoolean, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {

if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling apiVersionAnalyzePost.');
Expand All @@ -214,6 +231,16 @@ export class APIService {
throw new Error('Required parameter version was null or undefined when calling apiVersionAnalyzePost.');
}



let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
if (config !== undefined && config !== null) {
queryParameters = queryParameters.set('config', <any>config);
}
if (use_cached_result !== undefined && use_cached_result !== null) {
queryParameters = queryParameters.set('use-cached-result', <any>use_cached_result);
}

let headers = this.defaultHeaders;

// to determine the Accept header
Expand All @@ -234,9 +261,10 @@ export class APIService {
headers = headers.set('Content-Type', httpContentTypeSelected);
}

return this.httpClient.request<Problems>('post',`${this.basePath}/api/${encodeURIComponent(String(version))}/analyze`,
return this.httpClient.request<AnalyzeResponse>('post',`${this.basePath}/api/${encodeURIComponent(String(version))}/analyze`,
{
body: body,
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
Expand Down
4 changes: 3 additions & 1 deletion src/api/edulint/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export * from './aPI.service';
import { APIService } from './aPI.service';
export * from './default.service';
import { DefaultService } from './default.service';
export * from './web.service';
import { WebService } from './web.service';
export const APIS = [APIService, WebService];
export const APIS = [APIService, DefaultService, WebService];
Loading

0 comments on commit d5eacaa

Please sign in to comment.